def test_raise_bug_fetch_error_status_code(self, requests): """Return bug status.""" result = mock.MagicMock() result.status_code = 404 requests.get.side_effect = [result] with mock.patch.dict('robozilla.decorators._redmine', issues={}): with self.assertRaises(robozilla_decorators.BugFetchError): robozilla_decorators._get_redmine_bug_status_id('4242')
def test_raise_bug_fetch_error_status_code(self, requests): """Return bug status.""" result = mock.MagicMock() result.status_code = 404 requests.get.side_effect = [result] with mock.patch.dict('robozilla.decorators._redmine', issues={}): with self.assertRaises(robozilla_decorators.BugFetchError): robozilla_decorators._get_redmine_bug_status_id('4242')
def test_raise_bug_fetch_error_key_error(self, requests): """Return bug status.""" bug_id = '4242' result = mock.MagicMock() result.json.side_effect = [{'issue': {'status': {}}}] result.status_code = 200 requests.get.side_effect = [result] with mock.patch.dict('robozilla.decorators._redmine', issues={}): with self.assertRaises(robozilla_decorators.BugFetchError): robozilla_decorators._get_redmine_bug_status_id('4242') requests.get.assert_called_once_with('{0}/issues/{1}.json'.format( robozilla_decorators.REDMINE_URL, bug_id))
def test_raise_bug_fetch_error_key_error(self, requests): """Return bug status.""" bug_id = '4242' result = mock.MagicMock() result.json.side_effect = [{'issue': {'status': {}}}] result.status_code = 200 requests.get.side_effect = [result] with mock.patch.dict('robozilla.decorators._redmine', issues={}): with self.assertRaises(robozilla_decorators.BugFetchError): robozilla_decorators._get_redmine_bug_status_id('4242') requests.get.assert_called_once_with( '{0}/issues/{1}.json'.format( robozilla_decorators.REDMINE_URL, bug_id))
def test_not_cached_bug(self, requests): """Return bug status.""" bug_id = '4242' result = mock.MagicMock() result.json.side_effect = [{'issue': {'status': {'id': 42}}}] result.status_code = 200 requests.get.side_effect = [result] with mock.patch.dict('robozilla.decorators._redmine', issues={}): self.assertEqual( robozilla_decorators._get_redmine_bug_status_id('4242'), 42) requests.get.assert_called_once_with('{0}/issues/{1}.json'.format( robozilla_decorators.REDMINE_URL, bug_id))
def test_not_cached_bug(self, requests): """Return bug status.""" bug_id = '4242' result = mock.MagicMock() result.json.side_effect = [{'issue': {'status': {'id': 42}}}] result.status_code = 200 requests.get.side_effect = [result] with mock.patch.dict('robozilla.decorators._redmine', issues={}): self.assertEqual( robozilla_decorators._get_redmine_bug_status_id('4242'), 42) requests.get.assert_called_once_with( '{0}/issues/{1}.json'.format( robozilla_decorators.REDMINE_URL, bug_id))
def test_cached_bug(self): """Return bug status from the cache.""" with mock.patch.dict('robozilla.decorators._redmine', issues={'4242': 42}): self.assertEqual( robozilla_decorators._get_redmine_bug_status_id('4242'), 42)
def test_cached_bug(self): """Return bug status from the cache.""" with mock.patch.dict('robozilla.decorators._redmine', issues={'4242': 42}): self.assertEqual( robozilla_decorators._get_redmine_bug_status_id('4242'), 42)