Example #1
0
    def test_external_command_raises_oserror(self, mock_output):
        mock_output.side_effect = OSError()
        obj = BugzillaWorker(self.cfg, None)

        args = ["my", "args"]
        self.assertFalse(obj.external_command(args))
        mock_output.assert_called_once_with(args)
Example #2
0
    def test_external_command_raises_subprocess_error(self, mock_output):
        mock_output.side_effect = subprocess.CalledProcessError(1, "msg", b"output")
        obj = BugzillaWorker(self.cfg, None)

        args = ["my", "args"]
        self.assertFalse(obj.external_command(args))
        mock_output.assert_called_once_with(args)
Example #3
0
    def test_on_comment(self, mock_ext):
        obj = BugzillaWorker(self.cfg, None)
        args = obj._setup_default_args()
        args.extend(("modify", "1", "--comment=xfoo bary"))

        # Command succeeds
        mock_ext.return_value = True
        obj.on_comment({"bugid": 1, "commit": {"author_name": "foo bar"}})
        mock_ext.assert_called_once_with(args)

        # Command fails
        mock_ext.reset_mock()
        mock_ext.return_value = False
        obj.on_comment({"bugid": 1, "commit": {"author_name": "foo bar"}})
        mock_ext.assert_called_once_with(args)
Example #4
0
    def test_setup_default_command(self):
        obj = BugzillaWorker(self.cfg, None)

        expected = ["a_path", "--bugzilla=thebugzillaurl", "--user=username", "--password=password"]
        self.assertListEqual(expected, obj._setup_default_args())
Example #5
0
 def test_process_failed(self, mock_comment):
     obj = BugzillaWorker(self.cfg, None)
     obj.process({"task": "not_found"})
     self.assertFalse(mock_comment.called)
Example #6
0
 def test_process_ok(self, mock_comment):
     task = {"task": "comment"}
     obj = BugzillaWorker(self.cfg, None)
     obj.process(task)
     mock_comment.assert_called_once_with(task)
Example #7
0
    def test_external_command_ok(self, mock_output):
        obj = BugzillaWorker(self.cfg, None)

        args = ["my", "args"]
        self.assertTrue(obj.external_command(args))
        mock_output.assert_called_once_with(args)