def test_return_cache(self, requests): """Return the cache if already built.""" with mock.patch.dict('robozilla.decorators._redmine', closed_statuses=[42]): self.assertEqual( robozilla_decorators._redmine_closed_issue_statuses(), [42]) requests.get.assert_not_called()
def test_return_cache(self, requests): """Return the cache if already built.""" with mock.patch.dict( 'robozilla.decorators._redmine', closed_statuses=[42]): self.assertEqual( robozilla_decorators._redmine_closed_issue_statuses(), [42] ) requests.get.assert_not_called()
def test_build_cache(self, requests): """Build closed issue statuses cache.""" result = mock.MagicMock() result.json.side_effect = [{ 'issue_statuses': [{ 'id': 42, 'is_closed': True, }, { 'id': 12, 'is_closed': False, }] }] result.status_code = 200 requests.get.side_effect = [result] with mock.patch.dict('robozilla.decorators._redmine', closed_statuses=None): self.assertEqual( robozilla_decorators._redmine_closed_issue_statuses(), [42]) requests.get.assert_called_once_with('{0}/issue_statuses.json'.format( robozilla_decorators.REDMINE_URL))
def test_build_cache(self, requests): """Build closed issue statuses cache.""" result = mock.MagicMock() result.json.side_effect = [{ 'issue_statuses': [{ 'id': 42, 'is_closed': True, }, { 'id': 12, 'is_closed': False, }] }] result.status_code = 200 requests.get.side_effect = [result] with mock.patch.dict( 'robozilla.decorators._redmine', closed_statuses=None): self.assertEqual( robozilla_decorators._redmine_closed_issue_statuses(), [42] ) requests.get.assert_called_once_with( '{0}/issue_statuses.json'.format(robozilla_decorators.REDMINE_URL))