From aea222edbc57af44f1bdb66b56a09473f196fa71 Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Fri, 13 Dec 2013 16:28:55 +0000 Subject: [PATCH] Speed up nomcom tests a bit more by also only generating one certificate for the client per run - Legacy-Id: 6920 --- ietf/nomcom/test_data.py | 10 +++++----- ietf/nomcom/tests.py | 17 +++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ietf/nomcom/test_data.py b/ietf/nomcom/test_data.py index d6247cf29..3b49ece3e 100644 --- a/ietf/nomcom/test_data.py +++ b/ietf/nomcom/test_data.py @@ -93,7 +93,7 @@ def check_comments(encryped, plain, privatekey_file): return decrypted_comments == plain -test_cert_file = None +nomcom_test_cert_file = None def nomcom_test_data(): # groups @@ -104,10 +104,10 @@ def nomcom_test_data(): nomcom, created = NomCom.objects.get_or_create(group=group) - global test_cert_file - if not test_cert_file: - test_cert_file, privatekey_file = generate_cert() - nomcom.public_key.save('cert', File(open(test_cert_file.name, 'r'))) + global nomcom_test_cert_file + if not nomcom_test_cert_file: + nomcom_test_cert_file, privatekey_file = generate_cert() + nomcom.public_key.save('cert', File(open(nomcom_test_cert_file.name, 'r'))) # chair and member create_person(group, "chair", username=CHAIR_USER) diff --git a/ietf/nomcom/tests.py b/ietf/nomcom/tests.py index 283d1b868..569365831 100644 --- a/ietf/nomcom/tests.py +++ b/ietf/nomcom/tests.py @@ -27,6 +27,14 @@ from ietf.nomcom.forms import EditChairForm, EditChairFormPreview, EditMembersFo from ietf.nomcom.utils import get_nomcom_by_year, get_or_create_nominee from ietf.nomcom.management.commands.send_reminders import Command, is_time_to_send +client_test_cert_files = None + +def get_cert_files(): + global client_test_cert_files + if not client_test_cert_files: + client_test_cert_files = generate_cert() + return client_test_cert_files + class NomcomViewsTest(TestCase): """Tests to create a new nomcom""" @@ -39,7 +47,7 @@ class NomcomViewsTest(TestCase): def setUp(self): nomcom_test_data() - self.cert_file, self.privatekey_file = generate_cert() + self.cert_file, self.privatekey_file = get_cert_files() self.year = NOMCOM_YEAR # private urls @@ -651,7 +659,7 @@ class FeedbackTest(TestCase): def setUp(self): nomcom_test_data() - self.cert_file, self.privatekey_file = generate_cert() + self.cert_file, self.privatekey_file = get_cert_files() def test_encrypted_comments(self): @@ -675,16 +683,13 @@ class FeedbackTest(TestCase): self.assertEqual(check_comments(feedback.comments, comments, self.privatekey_file), True) - os.unlink(self.privatekey_file.name) - os.unlink(self.cert_file.name) - class ReminderTest(TestCase): perma_fixtures = ['nomcom_templates'] def setUp(self): nomcom_test_data() self.nomcom = get_nomcom_by_year(NOMCOM_YEAR) - self.cert_file, self.privatekey_file = generate_cert() + self.cert_file, self.privatekey_file = get_cert_files() self.nomcom.public_key.storage.location = tempfile.gettempdir() self.nomcom.public_key.save('cert', File(open(self.cert_file.name, 'r')))