summaryrefslogtreecommitdiff
path: root/gitlab/tests/test_gitlabobject.py
diff options
context:
space:
mode:
authorLyudmil Nenov <lyudmil.nenov@gmail.com>2017-11-03 16:05:17 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2017-11-03 15:05:17 +0100
commit226e6ce9e5217367c896125a2b4b9d16afd2cf94 (patch)
treea02b5fe4e9f235be3c2b9b128f931a99da03a0bc /gitlab/tests/test_gitlabobject.py
parent38d446737f45ea54136d1f03f75fbddf46c45e00 (diff)
downloadgitlab-226e6ce9e5217367c896125a2b4b9d16afd2cf94.tar.gz
Module's base objects serialization (#359)
Make gitlab objects serializable With current implementation of API v3 and v4 support, some instances have properties of type module and are not serializable. Handle these properties manually with setstate and getstate methods.
Diffstat (limited to 'gitlab/tests/test_gitlabobject.py')
-rw-r--r--gitlab/tests/test_gitlabobject.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/gitlab/tests/test_gitlabobject.py b/gitlab/tests/test_gitlabobject.py
index 695f900..f7fd187 100644
--- a/gitlab/tests/test_gitlabobject.py
+++ b/gitlab/tests/test_gitlabobject.py
@@ -21,6 +21,7 @@ from __future__ import print_function
from __future__ import absolute_import
import json
+import pickle
try:
import unittest
except ImportError:
@@ -158,6 +159,15 @@ class TestGitlabObject(unittest.TestCase):
self.assertEqual(data["username"], "testname")
self.assertEqual(data["gitlab"]["url"], "http://localhost/api/v3")
+ def test_pickability(self):
+ gl_object = CurrentUser(self.gl, data={"username": "testname"})
+ original_obj_module = gl_object._module
+ pickled = pickle.dumps(gl_object)
+ unpickled = pickle.loads(pickled)
+ self.assertIsInstance(unpickled, CurrentUser)
+ self.assertTrue(hasattr(unpickled, '_module'))
+ self.assertEqual(unpickled._module, original_obj_module)
+
def test_data_for_gitlab(self):
class FakeObj1(GitlabObject):
_url = '/fake1'