-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Change a few test case function signatures to be more pythonic
- Loading branch information
Showing
1 changed file
with
23 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -688,20 +688,16 @@ def test_public_nominate_with_automatic_questionnaire(self): | |
self.assertIn('nominee@', outbox[1]['To']) | ||
|
||
|
||
def nominate_view(self, *args, **kwargs): | ||
public = kwargs.pop('public', True) | ||
searched_email = kwargs.pop('searched_email', None) | ||
nominee_email = kwargs.pop('nominee_email', '[email protected]') | ||
def nominate_view(self, public=True, searched_email=None, | ||
nominee_email='[email protected]', | ||
nominator_email=COMMUNITY_USER+EMAIL_DOMAIN, | ||
position='IAOC', confirmation=False): | ||
|
||
if not searched_email: | ||
searched_email = Email.objects.filter(address=nominee_email).first() | ||
if not searched_email: | ||
searched_email = EmailFactory(address=nominee_email, primary=True, origin='test') | ||
searched_email = Email.objects.filter(address=nominee_email).first() or EmailFactory(address=nominee_email, primary=True, origin='test') | ||
if not searched_email.person: | ||
searched_email.person = PersonFactory() | ||
searched_email.save() | ||
nominator_email = kwargs.pop('nominator_email', "%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN)) | ||
position_name = kwargs.pop('position', 'IAOC') | ||
confirmation = kwargs.pop('confirmation', False) | ||
|
||
if public: | ||
nominate_url = self.public_nominate_url | ||
|
@@ -725,7 +721,7 @@ def nominate_view(self, *args, **kwargs): | |
q = PyQuery(response.content) | ||
self.assertEqual(len(q("#nominate-form")), 1) | ||
|
||
position = Position.objects.get(name=position_name) | ||
position = Position.objects.get(name=position) | ||
comment_text = 'Test nominate view. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' | ||
candidate_phone = '123456' | ||
|
||
|
@@ -763,12 +759,9 @@ def nominate_view(self, *args, **kwargs): | |
comments=feedback, | ||
nominator_email="%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN)) | ||
|
||
def nominate_newperson_view(self, *args, **kwargs): | ||
public = kwargs.pop('public', True) | ||
nominee_email = kwargs.pop('nominee_email', '[email protected]') | ||
nominator_email = kwargs.pop('nominator_email', "%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN)) | ||
position_name = kwargs.pop('position', 'IAOC') | ||
confirmation = kwargs.pop('confirmation', False) | ||
def nominate_newperson_view(self, public=True, nominee_email='[email protected]', | ||
nominator_email=COMMUNITY_USER+EMAIL_DOMAIN, | ||
position='IAOC', confirmation=False): | ||
|
||
if public: | ||
nominate_url = self.public_nominate_newperson_url | ||
|
@@ -792,7 +785,7 @@ def nominate_newperson_view(self, *args, **kwargs): | |
q = PyQuery(response.content) | ||
self.assertEqual(len(q("#nominate-form")), 1) | ||
|
||
position = Position.objects.get(name=position_name) | ||
position = Position.objects.get(name=position) | ||
candidate_email = nominee_email | ||
candidate_name = 'nominee' | ||
comment_text = 'Test nominate view. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' | ||
|
@@ -847,15 +840,13 @@ def test_add_questionnaire(self): | |
return self.add_questionnaire() | ||
self.client.logout() | ||
|
||
def add_questionnaire(self, *args, **kwargs): | ||
public = kwargs.pop('public', False) | ||
nominee_email = kwargs.pop('nominee_email', '[email protected]') | ||
nominator_email = kwargs.pop('nominator_email', "%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN)) | ||
position_name = kwargs.pop('position', 'IAOC') | ||
def add_questionnaire(self, public=False, nominee_email='[email protected]', | ||
nominator_email=COMMUNITY_USER+EMAIL_DOMAIN, | ||
position='IAOC'): | ||
|
||
self.nominate_view(public=public, | ||
nominee_email=nominee_email, | ||
position=position_name, | ||
position=position, | ||
nominator_email=nominator_email) | ||
|
||
response = self.client.get(self.add_questionnaire_url) | ||
|
@@ -874,7 +865,7 @@ def add_questionnaire(self, *args, **kwargs): | |
self.assertEqual(response.status_code, 200) | ||
self.assertContains(response, "questionnnaireform") | ||
|
||
position = Position.objects.get(name=position_name) | ||
position = Position.objects.get(name=position) | ||
nominee = Nominee.objects.get(email__address=nominee_email) | ||
|
||
comment_text = 'Test add questionnaire view. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' | ||
|
@@ -922,16 +913,13 @@ def test_private_feedback(self): | |
self.access_member_url(self.private_feedback_url) | ||
return self.feedback_view(public=False) | ||
|
||
def feedback_view(self, *args, **kwargs): | ||
public = kwargs.pop('public', True) | ||
nominee_email = kwargs.pop('nominee_email', '[email protected]') | ||
nominator_email = kwargs.pop('nominator_email', "%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN)) | ||
position_name = kwargs.pop('position', 'IAOC') | ||
confirmation = kwargs.pop('confirmation', False) | ||
def feedback_view(self, public=True, nominee_email='[email protected]', | ||
nominator_email=COMMUNITY_USER+EMAIL_DOMAIN, | ||
position='IAOC', confirmation=False): | ||
|
||
self.nominate_view(public=public, | ||
nominee_email=nominee_email, | ||
position=position_name, | ||
position=position, | ||
nominator_email=nominator_email) | ||
|
||
feedback_url = self.public_feedback_url | ||
|
@@ -954,7 +942,7 @@ def feedback_view(self, *args, **kwargs): | |
self.assertEqual(response.status_code, 200) | ||
self.assertNotContains(response, "feedbackform") | ||
|
||
position = Position.objects.get(name=position_name) | ||
position = Position.objects.get(name=position) | ||
nominee = Nominee.objects.get(email__address=nominee_email) | ||
|
||
feedback_url += "?nominee=%d&position=%d" % (nominee.id, position.id) | ||
|
@@ -970,7 +958,7 @@ def feedback_view(self, *args, **kwargs): | |
comments = 'Test feedback view. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' | ||
|
||
test_data = {'comment_text': comments, | ||
'position_name': position.name, | ||
'position': position.name, | ||
'nominee_name': nominee.email.person.name, | ||
'nominee_email': nominee.email.address, | ||
'confirmation': confirmation} | ||
|
@@ -2131,7 +2119,7 @@ def test_public_accepting_feedback(self): | |
self.assertIn('not currently accepting feedback', unicontent(response)) | ||
|
||
test_data = {'comment_text': 'junk', | ||
'position_name': pos.name, | ||
'position': pos.name, | ||
'nominee_name': pos.nominee_set.first().email.person.name, | ||
'nominee_email': pos.nominee_set.first().email.address, | ||
'confirmation': False, | ||
|