diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2017-11-11 15:40:13 +0100 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2017-11-11 15:40:13 +0100 |
commit | a1b097ce1811d320322a225d22183c36125b4a3c (patch) | |
tree | 89cfa2801fb806fcf592a72a3552a40c495307e7 /gitlab/tests | |
parent | 397d67745f573f1d6bcf9399e3ee602640b019c8 (diff) | |
download | gitlab-a1b097ce1811d320322a225d22183c36125b4a3c.tar.gz |
Add a SetMixin
Use it for UserCustomAttribute, will be useful for
{Project,Group}CustomAttribute (#367)
Diffstat (limited to 'gitlab/tests')
-rw-r--r-- | gitlab/tests/test_mixins.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gitlab/tests/test_mixins.py b/gitlab/tests/test_mixins.py index 812a118..c51322a 100644 --- a/gitlab/tests/test_mixins.py +++ b/gitlab/tests/test_mixins.py @@ -66,6 +66,13 @@ class TestObjectMixinsAttributes(unittest.TestCase): self.assertTrue(hasattr(obj, 'add_spent_time')) self.assertTrue(hasattr(obj, 'reset_spent_time')) + def test_set_mixin(self): + class O(SetMixin): + pass + + obj = O() + self.assertTrue(hasattr(obj, 'set')) + class TestMetaMixins(unittest.TestCase): def test_retrieve_mixin(self): @@ -409,3 +416,21 @@ class TestMixinMethods(unittest.TestCase): obj.save() self.assertEqual(obj._attrs['foo'], 'baz') self.assertDictEqual(obj._updated_attrs, {}) + + def test_set_mixin(self): + class M(SetMixin, FakeManager): + pass + + @urlmatch(scheme="http", netloc="localhost", path='/api/v4/tests/foo', + method="put") + def resp_cont(url, request): + headers = {'Content-Type': 'application/json'} + content = '{"key": "foo", "value": "bar"}' + return response(200, content, headers, None, 5, request) + + with HTTMock(resp_cont): + mgr = M(self.gl) + obj = mgr.set('foo', 'bar') + self.assertIsInstance(obj, FakeObject) + self.assertEqual(obj.key, 'foo') + self.assertEqual(obj.value, 'bar') |