def test_version(self, mock_print): with patch.object(sys, 'argv', ['reviewers.py', '-v']): with self.assertRaises(SystemExit): reviewers.main() self.assertTrue(mock_print.called) version = reviewers.__version__ + "\n" self.assertEqual(mock_print.call_args[0][0], version)
def test_phabricator_disabled_reviewers(self, mock_print): counter = Counter({'asdf': 1, 'qwer': 1}) get_reviewers = ('git_reviewers.reviewers.' 'FindFileLogReviewers.get_reviewers') with patch.object(sys, 'argv', ['reviewers.py']): with patch(get_reviewers) as mock_get_reviewers: with patch('subprocess.Popen') as mock_popen: mock_popen().communicate.return_value = \ [PHAB_DISABLED_DATA, b''] mock_get_reviewers.return_value = counter reviewers.main() self.assertEqual(mock_print.call_args[0][0], '')
def test_ignore_reviewers(self, mock_print): counter = Counter({'asdf': 1, 'qwer': 1}) get_reviewers = ('git_reviewers.reviewers.' 'FindFileLogReviewers.get_reviewers') run_command = 'git_reviewers.reviewers.FindReviewers.run_command' with patch.object(sys, 'argv', ['reviewers.py', '-i', 'asdf']): with patch(get_reviewers) as mock_get_reviewers: with patch(run_command) as mock_run_command: with patch('subprocess.Popen') as mock_popen: mock_popen().communicate.return_value = \ [PHAB_ACTIVATED_DATA, b''] mock_run_command.return_value = [] mock_get_reviewers.return_value = counter reviewers.main() self.assertEqual(mock_print.call_args[0][0], 'qwer')
def test_main(self, mock_print): with patch.object(sys, 'argv', ['reviewers.py']): reviewers.main() self.assertTrue(mock_print.called)