Speed up nomcom tests a bit more by also only generating one certificate for the client per run
- Legacy-Id: 6920
This commit is contained in:
parent
466928edc2
commit
aea222edbc
|
@ -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)
|
||||
|
|
|
@ -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')))
|
||||
|
||||
|
|
Loading…
Reference in a new issue