Skip to content

Commit

Permalink
Merge pull request servo#95 from davidalber/choose-reviewer-unit-tests
Browse files Browse the repository at this point in the history
More unit tests for `choose_reviewer`
  • Loading branch information
nrc authored Feb 24, 2018
2 parents ec40482 + f743b3a commit 7617642
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion highfive/tests/test_newpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def setUpClass(cls):
"groups": { "all": ["@pnkfelix", "@nrc"] },
"dirs": { "foobazdir": ["@aturon"] },
},
'circular_groups': {
"groups": {
"all": ["some"],
"some": ["all"],
},
},
'empty' :{
"groups": { "all": [] },
"dirs": {},
Expand All @@ -43,7 +49,10 @@ def setUpClass(cls):
"groups": {
"core": ["@alexcrichton"],
}
}
},
'has_all': {
"groups": { "all": ["@alexcrichton"] }
},
}

def choose_reviewer(
Expand Down Expand Up @@ -139,6 +148,15 @@ def test_individuals_no_dirs_2(self):
self.assertEqual(set(["pnkfelix"]), chosen_reviewers)
self.assertEqual(set([()]), mentions)

def test_circular_groups(self):
"""Test choosing a reviewer from groups that have circular references.
"""
self.assertRaises(
AssertionError, newpr.choose_reviewer, 'rust', 'rust-lang',
self.diff['normal'], 'fooauthor',
self.config['circular_groups']
)

def test_global_core(self):
"""Test choosing a reviewer from the core group in the global
configuration.
Expand All @@ -150,6 +168,18 @@ def test_global_core(self):
self.assertEqual(set(['alexcrichton']), chosen_reviewers)
self.assertEqual(set([()]), mentions)

@mock.patch('highfive.newpr._load_json_file')
def test_global_group_overlap(self, mock_load_json):
"""Test for an AssertionError when the global config contains a group
already defined in the config.
"""
mock_load_json.return_value = self.global_['has_all']
self.assertRaises(
AssertionError, newpr.choose_reviewer, 'rust', 'rust-lang',
self.diff['normal'], 'fooauthor',
self.config['individuals_no_dirs']
)

def test_no_potential_reviewers(self):
"""Test choosing a reviewer when nobody qualifies.
"""
Expand Down

0 comments on commit 7617642

Please sign in to comment.