Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
cslzchen committed Apr 5, 2017
1 parent b68d8cd commit f0f6a8c
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3488,6 +3488,7 @@ def setUp(self):
self.user_auth = AuthUserFactory()
self.auth = Auth(user=self.user_auth)
self.next_url = web_url_for('my_projects', _absolute=True)
self.invalid_campaign = 'invalid_campaign'

def test_osf_login_with_auth(self):
# login: user with auth
Expand Down Expand Up @@ -3600,7 +3601,7 @@ def test_campaign_register_with_auth(self):
assert_equal(data.get('status_code'), http.FOUND)
assert_equal(data.get('next_url'), campaign_url_for(campaign))

def test_campaign_register_without_campaign(self):
def test_campaign_register_without_auth(self):
for campaign in get_campaigns():
if is_institution_login(campaign):
continue
Expand Down Expand Up @@ -3668,6 +3669,31 @@ def test_campaign_next_url_register_without_auth(self):
web_url_for('auth_login', next= next_url, _absolute=True)
)

def test_invalid_campaign_login_without_auth(self):
data = login_and_register_handler(
self.no_auth,
login=True,
campaign=self.invalid_campaign,
next_url=self.next_url
)
redirect_url = web_url_for('auth_login', campaigns=None, next=self.next_url)
assert_equal(data['status_code'], http.FOUND)
assert_equal(data['next_url'], redirect_url)
assert_equal(data['campaign'], None)

def test_invalid_campaign_register_without_auth(self):
data = login_and_register_handler(
self.no_auth,
login=False,
campaign=self.invalid_campaign,
next_url=self.next_url
)
redirect_url = web_url_for('auth_register', campaigns=None, next=self.next_url)
assert_equal(data['status_code'], http.FOUND)
assert_equal(data['next_url'], redirect_url)
assert_equal(data['campaign'], None)


# The following two tests handles the special case for `claim_user_registered`
# When an authenticated user clicks the claim confirmation clink, there are two ways to trigger this flow:
# 1. If the authenticated user is already a contributor to the project, OSF will ask the user to sign out
Expand Down

0 comments on commit f0f6a8c

Please sign in to comment.