summaryrefslogtreecommitdiff
path: root/gitlab/tests/test_mixins.py
diff options
context:
space:
mode:
authorPierre Tardy <tardyp@gmail.com>2018-02-05 15:55:11 +0100
committerPierre Tardy <tardyp@gmail.com>2018-03-04 10:49:00 +0100
commit3424333bc98fcfc4733f2c5f1bf9a93b9a02135b (patch)
tree978ad66f1e18027d6e86ceeffa83e6a4ed08c474 /gitlab/tests/test_mixins.py
parent6bcc92a39a9a9dd97fa7387f754474c1cc5d78dc (diff)
downloadgitlab-3424333bc98fcfc4733f2c5f1bf9a93b9a02135b.tar.gz
introduce RefreshMixin
RefreshMixin allows to update a REST object so that you can poll on it. This is mostly useful for pipelines and jobs, but could be set on most of other objects, with unknown usecases.
Diffstat (limited to 'gitlab/tests/test_mixins.py')
-rw-r--r--gitlab/tests/test_mixins.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/gitlab/tests/test_mixins.py b/gitlab/tests/test_mixins.py
index c51322a..5c10597 100644
--- a/gitlab/tests/test_mixins.py
+++ b/gitlab/tests/test_mixins.py
@@ -153,6 +153,25 @@ class TestMixinMethods(unittest.TestCase):
self.assertEqual(obj.foo, 'bar')
self.assertEqual(obj.id, 42)
+ def test_refresh_mixin(self):
+ class O(RefreshMixin, FakeObject):
+ pass
+
+ @urlmatch(scheme="http", netloc="localhost", path='/api/v4/tests/42',
+ method="get")
+ def resp_cont(url, request):
+ headers = {'Content-Type': 'application/json'}
+ content = '{"id": 42, "foo": "bar"}'
+ return response(200, content, headers, None, 5, request)
+
+ with HTTMock(resp_cont):
+ mgr = FakeManager(self.gl)
+ obj = O(mgr, {'id': 42})
+ res = obj.refresh()
+ self.assertIsNone(res)
+ self.assertEqual(obj.foo, 'bar')
+ self.assertEqual(obj.id, 42)
+
def test_get_without_id_mixin(self):
class M(GetWithoutIdMixin, FakeManager):
pass