Skip to content

Commit aea222e

Browse files
committed
Speed up nomcom tests a bit more by also only generating one certificate for the client per run
- Legacy-Id: 6920
1 parent 466928e commit aea222e

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

ietf/nomcom/test_data.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def check_comments(encryped, plain, privatekey_file):
9393

9494
return decrypted_comments == plain
9595

96-
test_cert_file = None
96+
nomcom_test_cert_file = None
9797

9898
def nomcom_test_data():
9999
# groups
@@ -104,10 +104,10 @@ def nomcom_test_data():
104104

105105
nomcom, created = NomCom.objects.get_or_create(group=group)
106106

107-
global test_cert_file
108-
if not test_cert_file:
109-
test_cert_file, privatekey_file = generate_cert()
110-
nomcom.public_key.save('cert', File(open(test_cert_file.name, 'r')))
107+
global nomcom_test_cert_file
108+
if not nomcom_test_cert_file:
109+
nomcom_test_cert_file, privatekey_file = generate_cert()
110+
nomcom.public_key.save('cert', File(open(nomcom_test_cert_file.name, 'r')))
111111

112112
# chair and member
113113
create_person(group, "chair", username=CHAIR_USER)

ietf/nomcom/tests.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
from ietf.nomcom.utils import get_nomcom_by_year, get_or_create_nominee
2828
from ietf.nomcom.management.commands.send_reminders import Command, is_time_to_send
2929

30+
client_test_cert_files = None
31+
32+
def get_cert_files():
33+
global client_test_cert_files
34+
if not client_test_cert_files:
35+
client_test_cert_files = generate_cert()
36+
return client_test_cert_files
37+
3038

3139
class NomcomViewsTest(TestCase):
3240
"""Tests to create a new nomcom"""
@@ -39,7 +47,7 @@ def check_url_status(self, url, status):
3947

4048
def setUp(self):
4149
nomcom_test_data()
42-
self.cert_file, self.privatekey_file = generate_cert()
50+
self.cert_file, self.privatekey_file = get_cert_files()
4351
self.year = NOMCOM_YEAR
4452

4553
# private urls
@@ -651,7 +659,7 @@ class FeedbackTest(TestCase):
651659

652660
def setUp(self):
653661
nomcom_test_data()
654-
self.cert_file, self.privatekey_file = generate_cert()
662+
self.cert_file, self.privatekey_file = get_cert_files()
655663

656664
def test_encrypted_comments(self):
657665

@@ -675,16 +683,13 @@ def test_encrypted_comments(self):
675683

676684
self.assertEqual(check_comments(feedback.comments, comments, self.privatekey_file), True)
677685

678-
os.unlink(self.privatekey_file.name)
679-
os.unlink(self.cert_file.name)
680-
681686
class ReminderTest(TestCase):
682687
perma_fixtures = ['nomcom_templates']
683688

684689
def setUp(self):
685690
nomcom_test_data()
686691
self.nomcom = get_nomcom_by_year(NOMCOM_YEAR)
687-
self.cert_file, self.privatekey_file = generate_cert()
692+
self.cert_file, self.privatekey_file = get_cert_files()
688693
self.nomcom.public_key.storage.location = tempfile.gettempdir()
689694
self.nomcom.public_key.save('cert', File(open(self.cert_file.name, 'r')))
690695

0 commit comments

Comments
 (0)