Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Fixing the currently-inverted logic in is_new_contributor #129

Merged
merged 1 commit into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions highfive/newpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ def is_new_contributor(username, owner, repo, token, payload):
'GET', commit_search_url % (owner, repo, username), None, token,
'application/vnd.github.cloak-preview'
)
return json.loads(result['body'])['total_count'] > 0
return json.loads(result['body'])['total_count'] == 0
except urllib2.HTTPError, e:
if e.code == 422:
return False
return True
else:
raise e

Expand Down
6 changes: 3 additions & 3 deletions highfive/tests/integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ def setUp(self):
self.payload = {'repository': {'fork': False}}

def test_real_contributor_true(self):
self.assertTrue(
self.assertFalse(
newpr.is_new_contributor(
'nrc', 'rust-lang', 'rust', '', self.payload
)
)

def test_real_contributor_false(self):
self.assertFalse(
self.assertTrue(
newpr.is_new_contributor(
'octocat', 'rust-lang', 'rust', '', self.payload
)
)

def test_fake_user(self):
self.assertFalse(
self.assertTrue(
newpr.is_new_contributor(
'fjkesfgojsrgljsdgla', 'rust-lang', 'rust', '', self.payload
)
Expand Down
6 changes: 3 additions & 3 deletions highfive/tests/test_newpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,17 +626,17 @@ def test_is_new_contributor_fork(self):

def test_is_new_contributor_has_commits(self):
self.mocks['api_req'].return_value = self.api_return(5)
self.assertTrue(self.is_new_contributor())
self.assertFalse(self.is_new_contributor())
self.assert_api_req_call()

def test_is_new_contributor_no_commits(self):
self.mocks['api_req'].return_value = self.api_return(0)
self.assertFalse(self.is_new_contributor())
self.assertTrue(self.is_new_contributor())
self.assert_api_req_call()

def test_is_new_contributor_nonexistent_user(self):
self.mocks['api_req'].side_effect = HTTPError(None, 422, None, None, None)
self.assertFalse(self.is_new_contributor())
self.assertTrue(self.is_new_contributor())
self.assert_api_req_call()

def test_is_new_contributor_error(self):
Expand Down