示例#1
0
    def test_get_repositories(self):
        # Setup
        repos = [{
            'id': 'matching',
            'notes': {
                REPO_NOTE_TYPE_KEY: constants.REPO_NOTE_DEB,
            },
            'importers': [{
                'config': {}
            }],
            'distributors': [{
                'id': constants.CLI_WEB_DISTRIBUTOR_ID
            }]
        }, {
            'id': 'non-rpm-repo',
            'notes': {}
        }]
        self.context.server.repo.repositories.return_value.response_body = repos

        # Test
        command = cudl.ListDebRepositoriesCommand(self.context)
        repos = command.get_repositories({})

        # Verify
        self.assertEqual(1, len(repos))
        self.assertEqual(repos[0]['id'], 'matching')
示例#2
0
 def test_get_all_repos(self):
     self.context.server.repo.repositories.return_value.response_body = 'foo'
     command = cudl.ListDebRepositoriesCommand(self.context)
     result = command._all_repos({'bar': 'baz'})
     self.context.server.repo.repositories.assert_called_once_with(
         {'bar': 'baz'})
     self.assertEquals('foo', result)
示例#3
0
    def test_get_repositories_no_details(self):
        # Setup
        repos = [{
            'id': 'foo',
            'display_name': 'bar',
            'notes': {
                REPO_NOTE_TYPE_KEY: constants.REPO_NOTE_DEB,
            }
        }]
        self.context.server.repo.repositories.return_value.response_body = repos

        # Test
        command = cudl.ListDebRepositoriesCommand(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])
示例#4
0
 def test_get_all_repos_caches_results(self):
     command = cudl.ListDebRepositoriesCommand(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)