diff options
author | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2016-01-27 21:54:05 +0100 |
---|---|---|
committer | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2016-01-27 21:54:05 +0100 |
commit | 16d50cd5d52617d9117409ccc9819d8429088e84 (patch) | |
tree | 23c1a9c651aad411e443a97f2a3e4c4521ac69a9 /gitlab/tests/test_gitlabobject.py | |
parent | e5438c6440a2477c796427bc598b2b31b10dc762 (diff) | |
download | gitlab-16d50cd5d52617d9117409ccc9819d8429088e84.tar.gz |
Add support for application settings
Diffstat (limited to 'gitlab/tests/test_gitlabobject.py')
-rw-r--r-- | gitlab/tests/test_gitlabobject.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gitlab/tests/test_gitlabobject.py b/gitlab/tests/test_gitlabobject.py index 2726854..e001a8c 100644 --- a/gitlab/tests/test_gitlabobject.py +++ b/gitlab/tests/test_gitlabobject.py @@ -159,6 +159,45 @@ class TestGitlabObject(unittest.TestCase): self.assertEqual(data["username"], "testname") self.assertEqual(data["gitlab"]["url"], "http://localhost/api/v3") + def test_data_for_gitlab(self): + class FakeObj1(GitlabObject): + _url = '/fake1' + requiredCreateAttrs = ['create_req'] + optionalCreateAttrs = ['create_opt'] + requiredUpdateAttrs = ['update_req'] + optionalUpdateAttrs = ['update_opt'] + + class FakeObj2(GitlabObject): + _url = '/fake2' + requiredCreateAttrs = ['create_req'] + optionalCreateAttrs = ['create_opt'] + + obj1 = FakeObj1(self.gl, {'update_req': 1, 'update_opt': 1, + 'create_req': 1, 'create_opt': 1}) + obj2 = FakeObj2(self.gl, {'create_req': 1, 'create_opt': 1}) + + obj1_data = json.loads(obj1._data_for_gitlab()) + self.assertIn('create_req', obj1_data) + self.assertIn('create_opt', obj1_data) + self.assertNotIn('update_req', obj1_data) + self.assertNotIn('update_opt', obj1_data) + self.assertNotIn('gitlab', obj1_data) + + obj1_data = json.loads(obj1._data_for_gitlab(update=True)) + self.assertNotIn('create_req', obj1_data) + self.assertNotIn('create_opt', obj1_data) + self.assertIn('update_req', obj1_data) + self.assertIn('update_opt', obj1_data) + + obj1_data = json.loads(obj1._data_for_gitlab( + extra_parameters={'foo': 'bar'})) + self.assertIn('foo', obj1_data) + self.assertEqual(obj1_data['foo'], 'bar') + + obj2_data = json.loads(obj2._data_for_gitlab(update=True)) + self.assertIn('create_req', obj2_data) + self.assertIn('create_opt', obj2_data) + def test_list_not_implemented(self): self.assertRaises(NotImplementedError, CurrentUser.list, self.gl) |