class TestRepoGroupAPI(unittest.TestCase): def setUp(self): self.api = RepoGroupAPI(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_repo_groups(self): ret = self.api.repo_groups() self.api.server.GET.assert_called_once_with(self.api.PATH) self.assertEqual(ret, self.api.server.GET.return_value) def test_create(self): REPOGROUP = { 'id': 'rg1', 'display_name': 'repo group 1', 'description': 'great group', 'notes': { 'awesome': True } } ret = self.api.create(**REPOGROUP) self.api.server.POST.assert_called_once_with(self.api.PATH, REPOGROUP) def test_repogroup(self): ret = self.api.repo_group('rg1') expected_path = self.api.PATH + 'rg1/' self.api.server.GET.assert_called_once_with(expected_path) self.assertEqual(ret, self.api.server.GET.return_value) def test_delete(self): ret = self.api.delete('rg1') expected_path = self.api.PATH + 'rg1/' self.api.server.DELETE.assert_called_once_with(expected_path) self.assertEqual(ret, self.api.server.DELETE.return_value) def test_update(self): DELTA = {'display_name': 'foo'} ret = self.api.update('rg1', DELTA) expected_path = self.api.PATH + 'rg1/' self.api.server.PUT.assert_called_once_with(expected_path, DELTA) self.assertEqual(ret, self.api.server.PUT.return_value)
class TestRepoGroupAPI(unittest.TestCase): def setUp(self): self.api = RepoGroupAPI(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_repo_groups(self): ret = self.api.repo_groups() self.api.server.GET.assert_called_once_with(self.api.PATH) self.assertEqual(ret, self.api.server.GET.return_value) def test_create(self): REPOGROUP = { 'id' : 'rg1', 'display_name' : 'repo group 1', 'description' : 'great group', 'notes' : {'awesome' : True} } ret = self.api.create(**REPOGROUP) self.api.server.POST.assert_called_once_with(self.api.PATH, REPOGROUP) def test_repogroup(self): ret = self.api.repo_group('rg1') expected_path = self.api.PATH + 'rg1/' self.api.server.GET.assert_called_once_with(expected_path) self.assertEqual(ret, self.api.server.GET.return_value) def test_delete(self): ret = self.api.delete('rg1') expected_path = self.api.PATH + 'rg1/' self.api.server.DELETE.assert_called_once_with(expected_path) self.assertEqual(ret, self.api.server.DELETE.return_value) def test_update(self): DELTA = {'display_name':'foo'} ret = self.api.update('rg1', DELTA) expected_path = self.api.PATH + 'rg1/' self.api.server.PUT.assert_called_once_with(expected_path, DELTA) self.assertEqual(ret, self.api.server.PUT.return_value)
class TestRepoGroupAPI(unittest.TestCase): def setUp(self): self.api = RepoGroupAPI(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_repo_groups(self): ret = self.api.repo_groups() self.api.server.GET.assert_called_once_with(self.api.PATH) self.assertEqual(ret, self.api.server.GET.return_value) def test_create(self): REPOGROUP = { 'id': 'rg1', 'display_name': 'repo group 1', 'description': 'great group', 'notes': { 'awesome': True } } ret = self.api.create(**REPOGROUP) self.api.server.POST.assert_called_once_with(self.api.PATH, REPOGROUP) def test_create_and_configure(self): """ Test that create_and_configure results in the correct call to POST and returns whatever POST returns """ # Setup group_id, display_name, description = 'test_id', 'test group', 'test description' distributors = [{'fake': 'distributor'}] notes = {'key': True} expected_repo_group = { 'id': group_id, 'display_name': display_name, 'description': description, 'notes': notes, 'distributors': distributors, } # Test result = self.api.create_and_configure(group_id, display_name, description, notes, distributors) self.api.server.POST.assert_called_once_with(self.api.PATH, expected_repo_group) self.assertEqual(result, self.api.server.POST.return_value) def test_repogroup(self): ret = self.api.repo_group('rg1') expected_path = self.api.PATH + 'rg1/' self.api.server.GET.assert_called_once_with(expected_path) self.assertEqual(ret, self.api.server.GET.return_value) def test_delete(self): ret = self.api.delete('rg1') expected_path = self.api.PATH + 'rg1/' self.api.server.DELETE.assert_called_once_with(expected_path) self.assertEqual(ret, self.api.server.DELETE.return_value) def test_update(self): DELTA = {'display_name': 'foo'} ret = self.api.update('rg1', DELTA) expected_path = self.api.PATH + 'rg1/' self.api.server.PUT.assert_called_once_with(expected_path, DELTA) self.assertEqual(ret, self.api.server.PUT.return_value)
class TestRepoGroupAPI(unittest.TestCase): def setUp(self): self.api = RepoGroupAPI(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_repo_groups(self): ret = self.api.repo_groups() self.api.server.GET.assert_called_once_with(self.api.PATH) self.assertEqual(ret, self.api.server.GET.return_value) def test_create(self): REPOGROUP = { 'id' : 'rg1', 'display_name' : 'repo group 1', 'description' : 'great group', 'notes' : {'awesome' : True} } ret = self.api.create(**REPOGROUP) self.api.server.POST.assert_called_once_with(self.api.PATH, REPOGROUP) def test_create_and_configure(self): """ Test that create_and_configure results in the correct call to POST and returns whatever POST returns """ # Setup group_id, display_name, description = 'test_id', 'test group', 'test description' distributors = [{'fake': 'distributor'}] notes = {'key': True} expected_repo_group = { 'id': group_id, 'display_name': display_name, 'description': description, 'notes': notes, 'distributors': distributors, } # Test result = self.api.create_and_configure(group_id, display_name, description, notes, distributors) self.api.server.POST.assert_called_once_with(self.api.PATH, expected_repo_group) self.assertEqual(result, self.api.server.POST.return_value) def test_repogroup(self): ret = self.api.repo_group('rg1') expected_path = self.api.PATH + 'rg1/' self.api.server.GET.assert_called_once_with(expected_path) self.assertEqual(ret, self.api.server.GET.return_value) def test_delete(self): ret = self.api.delete('rg1') expected_path = self.api.PATH + 'rg1/' self.api.server.DELETE.assert_called_once_with(expected_path) self.assertEqual(ret, self.api.server.DELETE.return_value) def test_update(self): DELTA = {'display_name':'foo'} ret = self.api.update('rg1', DELTA) expected_path = self.api.PATH + 'rg1/' self.api.server.PUT.assert_called_once_with(expected_path, DELTA) self.assertEqual(ret, self.api.server.PUT.return_value)