def test_get_repositories(self): # Setup repos = [ { 'id': 'matching', 'notes': {REPO_NOTE_TYPE_KEY: constants.REPO_NOTE_PYTHON, }, 'importers': [ {'config': {}} ], 'distributors': [ {'id': constants.CLI_DISTRIBUTOR_ID} ] }, {'id': 'non-rpm-repo', 'notes': {}} ] self.context.server.repo.repositories.return_value.response_body = repos # Test command = cudl.ListPythonRepositoriesCommand(self.context) repos = command.get_repositories({}) # Verify self.assertEqual(1, len(repos)) self.assertEqual(repos[0]['id'], 'matching')
def test_get_all_repos(self): self.context.server.repo.repositories.return_value.response_body = 'foo' command = cudl.ListPythonRepositoriesCommand(self.context) result = command._all_repos({'bar': 'baz'}) self.context.server.repo.repositories.assert_called_once_with( {'bar': 'baz'}) self.assertEquals('foo', result)
def test_get_repositories_no_details(self): # Setup repos = [ { 'id': 'foo', 'display_name': 'bar', 'notes': {REPO_NOTE_TYPE_KEY: constants.REPO_NOTE_PYTHON, } } ] self.context.server.repo.repositories.return_value.response_body = repos # Test command = cudl.ListPythonRepositoriesCommand(self.context) repos = command.get_repositories({}) # Verify self.assertEqual(1, len(repos)) self.assertEqual(repos[0]['id'], 'foo') self.assertTrue('importers' not in repos[0]) self.assertTrue('distributors' not in repos[0])
def test_get_all_repos_caches_results(self): command = cudl.ListPythonRepositoriesCommand(self.context) command.all_repos_cache = 'foo' result = command._all_repos({'bar': 'baz'}) self.assertFalse(self.context.server.repo.repositories.called) self.assertEquals('foo', result)