def test_get_repo(self): """ get_repo_or_missing_resource should return self.get if the repo exists. """ qs = querysets.RepoQuerySet(mock.MagicMock(), mock.MagicMock()) mock_get = mock.MagicMock() qs.get = mock_get result = qs.get_repo_or_missing_resource('repo') mock_get.assert_called_once_with(repo_id='repo') self.assertTrue(result is mock_get.return_value)
def test_get_missing_repo(self): """ Raise a MissingResource if the repo does not exist. """ qs = querysets.RepoQuerySet(mock.MagicMock(), mock.MagicMock()) mock_get = mock.MagicMock() mock_get.side_effect = DoesNotExist qs.get = mock_get self.assertRaises(pulp_exceptions.MissingResource, qs.get_repo_or_missing_resource, 'repo') mock_get.assert_called_once_with(repo_id='repo')
def test_cache_not_implemented(self): """Assert that calling `cache` results in an exception.""" qs = querysets.RepoQuerySet(mock.MagicMock(), mock.MagicMock()) self.assertRaises(NotImplementedError, qs.cache)