示例#1
0
class TestRepositoryUpdateAPI(unittest.TestCase):
    def setUp(self):
        self.api = RepositoryAPI(mock.MagicMock(spec=PulpConnection))
        self.expected_path = self.api.base_path + "foo/"
        self.repo_id = 'foo'

    def test_repo_only(self):

        self.api.update(self.repo_id, {'baz': 'qux'})
        expected_body = {'delta': {'baz': 'qux'}}
        self.api.server.PUT.assert_called_once_with(self.expected_path,
                                                    expected_body)

    def test_distributors(self):
        self.api.update(self.repo_id, {},
                        distributor_configs={'foo': {
                            'bar': 'baz'
                        }})
        expected_body = {
            'delta': {},
            'distributor_configs': {
                'foo': {
                    'bar': 'baz'
                }
            }
        }
        self.api.server.PUT.assert_called_once_with(self.expected_path,
                                                    expected_body)

    def test_importer(self):
        self.api.update(self.repo_id, {}, importer_config={'foo': 'bar'})
        expected_body = {'delta': {}, 'importer_config': {'foo': 'bar'}}
        self.api.server.PUT.assert_called_once_with(self.expected_path,
                                                    expected_body)
示例#2
0
class TestRepositoryUpdateAPI(unittest.TestCase):

    def setUp(self):
        self.api = RepositoryAPI(mock.MagicMock(spec=PulpConnection))
        self.expected_path = self.api.base_path + "foo/"
        self.repo_id = 'foo'

    def test_repo_only(self):

        self.api.update(self.repo_id, {'baz': 'qux'})
        expected_body = {'delta': {'baz': 'qux'}}
        self.api.server.PUT.assert_called_once_with(self.expected_path, expected_body)

    def test_distributors(self):
        self.api.update(self.repo_id, {}, distributor_configs={'foo': {'bar': 'baz'}})
        expected_body = {'delta': {}, 'distributor_configs': {'foo': {'bar': 'baz'}}}
        self.api.server.PUT.assert_called_once_with(self.expected_path, expected_body)

    def test_importer(self):
        self.api.update(self.repo_id, {}, importer_config={'foo': 'bar'})
        expected_body = {'delta': {}, 'importer_config': {'foo': 'bar'}}
        self.api.server.PUT.assert_called_once_with(self.expected_path, expected_body)