1818from django .core .files import File
1919from django .contrib .auth .models import User
2020from django .urls import reverse
21- from django .utils .encoding import force_text
21+ from django .utils .encoding import force_text , force_str
2222
2323import debug # pyflakes:ignore
2424
@@ -52,12 +52,12 @@ def get_cert_files():
5252 client_test_cert_files = generate_cert ()
5353 return client_test_cert_files
5454
55- def build_test_public_keys_dir (obj ):
55+ def setup_test_public_keys_dir (obj ):
5656 obj .saved_nomcom_public_keys_dir = settings .NOMCOM_PUBLIC_KEYS_DIR
5757 obj .nomcom_public_keys_dir = obj .tempdir ('nomcom-public-keys' )
5858 settings .NOMCOM_PUBLIC_KEYS_DIR = obj .nomcom_public_keys_dir
5959
60- def clean_test_public_keys_dir (obj ):
60+ def teardown_test_public_keys_dir (obj ):
6161 settings .NOMCOM_PUBLIC_KEYS_DIR = obj .saved_nomcom_public_keys_dir
6262 shutil .rmtree (obj .nomcom_public_keys_dir )
6363
@@ -70,7 +70,7 @@ def check_url_status(self, url, status):
7070 return response
7171
7272 def setUp (self ):
73- build_test_public_keys_dir (self )
73+ setup_test_public_keys_dir (self )
7474 nomcom_test_data ()
7575 self .cert_file , self .privatekey_file = get_cert_files ()
7676 self .year = NOMCOM_YEAR
@@ -99,7 +99,7 @@ def setUp(self):
9999 self .public_nominate_newperson_url = reverse ('ietf.nomcom.views.public_nominate_newperson' , kwargs = {'year' : self .year })
100100
101101 def tearDown (self ):
102- clean_test_public_keys_dir (self )
102+ teardown_test_public_keys_dir (self )
103103
104104 def access_member_url (self , url ):
105105 login_testing_unauthorized (self , COMMUNITY_USER , url )
@@ -943,12 +943,12 @@ class NomineePositionStateSaveTest(TestCase):
943943 """Tests for the NomineePosition save override method"""
944944
945945 def setUp (self ):
946- build_test_public_keys_dir (self )
946+ setup_test_public_keys_dir (self )
947947 nomcom_test_data ()
948948 self .nominee = Nominee .objects .get (email__person__user__username = COMMUNITY_USER )
949949
950950 def tearDown (self ):
951- clean_test_public_keys_dir (self )
951+ teardown_test_public_keys_dir (self )
952952
953953 def test_state_autoset (self ):
954954 """Verify state is autoset correctly"""
@@ -978,13 +978,13 @@ def test_nomine_position_unique(self):
978978class FeedbackTest (TestCase ):
979979
980980 def setUp (self ):
981- build_test_public_keys_dir (self )
981+ setup_test_public_keys_dir (self )
982982
983983 nomcom_test_data ()
984984 self .cert_file , self .privatekey_file = get_cert_files ()
985985
986986 def tearDown (self ):
987- clean_test_public_keys_dir (self )
987+ teardown_test_public_keys_dir (self )
988988
989989 def test_encrypted_comments (self ):
990990
@@ -1011,7 +1011,7 @@ def test_encrypted_comments(self):
10111011class ReminderTest (TestCase ):
10121012
10131013 def setUp (self ):
1014- build_test_public_keys_dir (self )
1014+ setup_test_public_keys_dir (self )
10151015 nomcom_test_data ()
10161016 self .nomcom = get_nomcom_by_year (NOMCOM_YEAR )
10171017 self .cert_file , self .privatekey_file = get_cert_files ()
@@ -1053,7 +1053,7 @@ def setUp(self):
10531053 feedback .nominees .add (n )
10541054
10551055 def tearDown (self ):
1056- clean_test_public_keys_dir (self )
1056+ teardown_test_public_keys_dir (self )
10571057
10581058 def test_is_time_to_send (self ):
10591059 self .nomcom .reminder_interval = 4
@@ -1109,14 +1109,14 @@ def test_remind_questionnaire_view(self):
11091109class InactiveNomcomTests (TestCase ):
11101110
11111111 def setUp (self ):
1112- build_test_public_keys_dir (self )
1112+ setup_test_public_keys_dir (self )
11131113 self .nc = NomComFactory .create (** nomcom_kwargs_for_year (group__state_id = 'conclude' ))
11141114 self .plain_person = PersonFactory .create ()
11151115 self .chair = self .nc .group .role_set .filter (name = 'chair' ).first ().person
11161116 self .member = self .nc .group .role_set .filter (name = 'member' ).first ().person
11171117
11181118 def tearDown (self ):
1119- clean_test_public_keys_dir (self )
1119+ teardown_test_public_keys_dir (self )
11201120
11211121 def test_feedback_closed (self ):
11221122 for view in ['ietf.nomcom.views.public_feedback' , 'ietf.nomcom.views.private_feedback' ]:
@@ -1303,7 +1303,7 @@ def test_can_view_but_not_edit_templates(self):
13031303class FeedbackLastSeenTests (TestCase ):
13041304
13051305 def setUp (self ):
1306- build_test_public_keys_dir (self )
1306+ setup_test_public_keys_dir (self )
13071307 self .nc = NomComFactory .create (** nomcom_kwargs_for_year ())
13081308 self .author = PersonFactory .create ().email_set .first ().address
13091309 self .member = self .nc .group .role_set .filter (name = 'member' ).first ().person
@@ -1322,7 +1322,7 @@ def setUp(self):
13221322 self .second_from_now = now + datetime .timedelta (seconds = 1 )
13231323
13241324 def tearDown (self ):
1325- clean_test_public_keys_dir (self )
1325+ teardown_test_public_keys_dir (self )
13261326
13271327 def test_feedback_index_badges (self ):
13281328 url = reverse ('ietf.nomcom.views.view_feedback' ,kwargs = {'year' :self .nc .year ()})
@@ -1409,13 +1409,13 @@ def test_feedback_topic_badges(self):
14091409class NewActiveNomComTests (TestCase ):
14101410
14111411 def setUp (self ):
1412- build_test_public_keys_dir (self )
1412+ setup_test_public_keys_dir (self )
14131413 self .nc = NomComFactory .create (** nomcom_kwargs_for_year ())
14141414 self .chair = self .nc .group .role_set .filter (name = 'chair' ).first ().person
14151415 self .saved_days_to_expire_nomination_link = settings .DAYS_TO_EXPIRE_NOMINATION_LINK
14161416
14171417 def tearDown (self ):
1418- clean_test_public_keys_dir (self )
1418+ teardown_test_public_keys_dir (self )
14191419 settings .DAYS_TO_EXPIRE_NOMINATION_LINK = self .saved_days_to_expire_nomination_link
14201420
14211421 def test_help (self ):
@@ -1485,7 +1485,7 @@ def test_provide_private_key(self):
14851485 login_testing_unauthorized (self ,self .chair .user .username ,url )
14861486 response = self .client .get (url )
14871487 self .assertEqual (response .status_code ,200 )
1488- response = self .client .post (url ,{'key' :key })
1488+ response = self .client .post (url ,{'key' : force_str ( key ) })
14891489 self .assertEqual (response .status_code ,302 )
14901490
14911491 def test_email_pasting (self ):
@@ -1872,13 +1872,13 @@ def test_not_yet(self):
18721872
18731873class AcceptingTests (TestCase ):
18741874 def setUp (self ):
1875- build_test_public_keys_dir (self )
1875+ setup_test_public_keys_dir (self )
18761876 self .nc = NomComFactory (** nomcom_kwargs_for_year ())
18771877 self .plain_person = PersonFactory .create ()
18781878 self .member = self .nc .group .role_set .filter (name = 'member' ).first ().person
18791879
18801880 def tearDown (self ):
1881- clean_test_public_keys_dir (self )
1881+ teardown_test_public_keys_dir (self )
18821882
18831883 def test_public_accepting_nominations (self ):
18841884 url = reverse ('ietf.nomcom.views.public_nominate' ,kwargs = {'year' :self .nc .year ()})
@@ -1979,12 +1979,12 @@ def test_private_accepting_feedback(self):
19791979
19801980class ShowNomineeTests (TestCase ):
19811981 def setUp (self ):
1982- build_test_public_keys_dir (self )
1982+ setup_test_public_keys_dir (self )
19831983 self .nc = NomComFactory (** nomcom_kwargs_for_year ())
19841984 self .plain_person = PersonFactory .create ()
19851985
19861986 def tearDown (self ):
1987- clean_test_public_keys_dir (self )
1987+ teardown_test_public_keys_dir (self )
19881988
19891989 def test_feedback_pictures (self ):
19901990 url = reverse ('ietf.nomcom.views.public_nominate' ,kwargs = {'year' :self .nc .year ()})
@@ -2000,13 +2000,13 @@ def test_feedback_pictures(self):
20002000
20012001class TopicTests (TestCase ):
20022002 def setUp (self ):
2003- build_test_public_keys_dir (self )
2003+ setup_test_public_keys_dir (self )
20042004 self .nc = NomComFactory (** nomcom_kwargs_for_year (populate_topics = False ))
20052005 self .plain_person = PersonFactory .create ()
20062006 self .chair = self .nc .group .role_set .filter (name = 'chair' ).first ().person
20072007
20082008 def tearDown (self ):
2009- clean_test_public_keys_dir (self )
2009+ teardown_test_public_keys_dir (self )
20102010
20112011 def testAddEditListRemoveTopic (self ):
20122012 self .assertFalse (self .nc .topic_set .exists ())
0 commit comments