Ejemplo n.º 1
0
class TestRepoGroupActionAPI(unittest.TestCase):
    def setUp(self):
        self.api = RepoGroupActionAPI(mock.MagicMock())

    def test_path(self):
        self.assertTrue(isinstance(self.api.PATH, basestring))
        self.assertTrue(len(self.api.PATH) > 0)
        # this should be a relative path, and thus not start with a '/'
        self.assertFalse(self.api.PATH.startswith('/'))

    def test_associate(self):
        ret = self.api.associate('rg1', match=[('name', 'foo')])
        EXPECTED = {'criteria': {'filters': {'name': {'$regex' : 'foo'}}}}
        self.api.server.POST.assert_called_once_with(
            'v2/repo_groups/rg1/actions/associate/', EXPECTED)
        self.assertEqual(ret, self.api.server.POST.return_value.response_body)

    def test_unassociate(self):
        ret = self.api.unassociate('rg1', match=[('name', 'foo')])
        EXPECTED = {'criteria': {'filters': {'name': {'$regex' : 'foo'}}}}
        self.api.server.POST.assert_called_once_with(
            'v2/repo_groups/rg1/actions/unassociate/', EXPECTED)
        self.assertEqual(ret, self.api.server.POST.return_value.response_body)

    def test_publish(self):
        """
        Test publishing a repository group results in the correct POST
        """
        result = self.api.publish('repo_group1', 'distributor_id', {'config': 'value'})
        expected_data = {'id': 'distributor_id', 'override_config': {'config': 'value'}}
        self.api.server.POST.assert_called_once_with(
            'v2/repo_groups/repo_group1/actions/publish/', expected_data)
        self.assertEqual(result, self.api.server.POST.return_value)
Ejemplo n.º 2
0
class TestRepoGroupActionAPI(unittest.TestCase):
    def setUp(self):
        self.api = RepoGroupActionAPI(mock.MagicMock())

    def test_path(self):
        self.assertTrue(isinstance(self.api.PATH, basestring))
        self.assertTrue(len(self.api.PATH) > 0)
        # this should be a relative path, and thus not start with a '/'
        self.assertFalse(self.api.PATH.startswith('/'))

    def test_associate(self):
        ret = self.api.associate('rg1', match=[('name', 'foo')])
        EXPECTED = {'criteria': {'filters': {'name': {'$regex': 'foo'}}}}
        self.api.server.POST.assert_called_once_with(
            'v2/repo_groups/rg1/actions/associate/', EXPECTED)
        self.assertEqual(ret, self.api.server.POST.return_value.response_body)

    def test_unassociate(self):
        ret = self.api.unassociate('rg1', match=[('name', 'foo')])
        EXPECTED = {'criteria': {'filters': {'name': {'$regex': 'foo'}}}}
        self.api.server.POST.assert_called_once_with(
            'v2/repo_groups/rg1/actions/unassociate/', EXPECTED)
        self.assertEqual(ret, self.api.server.POST.return_value.response_body)

    def test_publish(self):
        """
        Test publishing a repository group results in the correct POST
        """
        result = self.api.publish('repo_group1', 'distributor_id',
                                  {'config': 'value'})
        expected_data = {
            'id': 'distributor_id',
            'override_config': {
                'config': 'value'
            }
        }
        self.api.server.POST.assert_called_once_with(
            'v2/repo_groups/repo_group1/actions/publish/', expected_data)
        self.assertEqual(result, self.api.server.POST.return_value)
Ejemplo n.º 3
0
class TestRepoGroupActionAPI(unittest.TestCase):
    def setUp(self):
        self.api = RepoGroupActionAPI(mock.MagicMock())

    def test_path(self):
        self.assertTrue(isinstance(self.api.PATH, basestring))
        self.assertTrue(len(self.api.PATH) > 0)
        # this should be a relative path, and thus not start with a '/'
        self.assertFalse(self.api.PATH.startswith('/'))

    def test_associate(self):
        ret = self.api.associate('rg1', match=[('name', 'foo')])
        EXPECTED = {'criteria': {'filters': {'name': {'$regex': 'foo'}}}}
        self.api.server.POST.assert_called_once_with(
            'v2/repo_groups/rg1/actions/associate/', EXPECTED)
        self.assertEqual(ret, self.api.server.POST.return_value.response_body)

    def test_unassociate(self):
        ret = self.api.unassociate('rg1', match=[('name', 'foo')])
        EXPECTED = {'criteria': {'filters': {'name': {'$regex': 'foo'}}}}
        self.api.server.POST.assert_called_once_with(
            'v2/repo_groups/rg1/actions/unassociate/', EXPECTED)
        self.assertEqual(ret, self.api.server.POST.return_value.response_body)
Ejemplo n.º 4
0
class TestRepoGroupActionAPI(unittest.TestCase):
    def setUp(self):
        self.api = RepoGroupActionAPI(mock.MagicMock())

    def test_path(self):
        self.assertTrue(isinstance(self.api.PATH, basestring))
        self.assertTrue(len(self.api.PATH) > 0)
        # this should be a relative path, and thus not start with a '/'
        self.assertFalse(self.api.PATH.startswith('/'))

    def test_associate(self):
        ret = self.api.associate('rg1', match=[('name', 'foo')])
        EXPECTED = {'criteria': {'filters': {'name': {'$regex' : 'foo'}}}}
        self.api.server.POST.assert_called_once_with(
            'v2/repo_groups/rg1/actions/associate/', EXPECTED)
        self.assertEqual(ret, self.api.server.POST.return_value.response_body)

    def test_unassociate(self):
        ret = self.api.unassociate('rg1', match=[('name', 'foo')])
        EXPECTED = {'criteria': {'filters': {'name': {'$regex' : 'foo'}}}}
        self.api.server.POST.assert_called_once_with(
            'v2/repo_groups/rg1/actions/unassociate/', EXPECTED)
        self.assertEqual(ret, self.api.server.POST.return_value.response_body)