summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain.pocentek@objectif-libre.com>2015-12-31 07:02:12 +0100
committerGauvain Pocentek <gauvain.pocentek@objectif-libre.com>2015-12-31 07:02:12 +0100
commit2a76b7490ba3dc6de6080d2dab55be017c09db59 (patch)
tree26650bd3b5a07b773d38fe8ada3f7bf9071ce0ca
parenta636d5ab25d2b248d89363ac86ecad7a0b90f100 (diff)
downloadgitlab-2a76b7490ba3dc6de6080d2dab55be017c09db59.tar.gz
Rename the _created attribute _from_api
-rw-r--r--gitlab/__init__.py17
-rw-r--r--gitlab/tests/test_gitlab.py4
-rw-r--r--gitlab/tests/test_gitlabobject.py6
3 files changed, 13 insertions, 14 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index ab4fc87..7b23903 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -351,9 +351,9 @@ class Gitlab(object):
cls_kwargs = kwargs.copy()
- # Add _created manually, because we are not creating objects
+ # Add _from_api manually, because we are not creating objects
# through normal path
- cls_kwargs['_created'] = True
+ cls_kwargs['_from_api'] = True
get_all_results = params.get('all', False)
@@ -536,7 +536,7 @@ class Gitlab(object):
l = []
for o in r.json():
p = Project(self, o)
- p._created = True
+ p._from_api = True
l.append(p)
return l
@@ -737,7 +737,7 @@ class GitlabObject(object):
json = self.gitlab.create(self, **kwargs)
self._set_from_dict(json)
- self._created = True
+ self._from_api = True
def _update(self, **kwargs):
if not self.canUpdate:
@@ -747,7 +747,7 @@ class GitlabObject(object):
self._set_from_dict(json)
def save(self, **kwargs):
- if self._created:
+ if self._from_api:
self._update(**kwargs)
else:
self._create(**kwargs)
@@ -756,7 +756,7 @@ class GitlabObject(object):
if not self.canDelete:
raise NotImplementedError
- if not self._created:
+ if not self._from_api:
raise GitlabDeleteError("Object not yet created")
return self.gitlab.delete(self, **kwargs)
@@ -772,7 +772,7 @@ class GitlabObject(object):
return obj
def __init__(self, gl, data=None, **kwargs):
- self._created = False
+ self._from_api = False
self.gitlab = gl
if (data is None or isinstance(data, six.integer_types) or
@@ -780,8 +780,7 @@ class GitlabObject(object):
if not self.canGet:
raise NotImplementedError
data = self.gitlab.get(self.__class__, data, **kwargs)
- # Object is created because we got it from api
- self._created = True
+ self._from_api = True
self._set_from_dict(data)
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py
index 60cb94e..a0f35bb 100644
--- a/gitlab/tests/test_gitlab.py
+++ b/gitlab/tests/test_gitlab.py
@@ -337,7 +337,7 @@ class TestGitLabMethods(unittest.TestCase):
def test_delete_unknown_path(self):
obj = Project(self.gl, data={"name": "testname", "id": 1})
- obj._created = True
+ obj._from_api = True
@urlmatch(scheme="http", netloc="localhost", path="/api/v3/projects/1",
method="delete")
@@ -398,7 +398,7 @@ class TestGitLabMethods(unittest.TestCase):
obj = User(self.gl, data={"email": "email", "password": "password",
"username": "username", "name": "name",
"can_create_group": True})
- obj._created = True
+ obj._from_api = True
@urlmatch(scheme="http", netloc="localhost", path="/api/v3/projects/1",
method="delete")
diff --git a/gitlab/tests/test_gitlabobject.py b/gitlab/tests/test_gitlabobject.py
index 01e954b..812e6c6 100644
--- a/gitlab/tests/test_gitlabobject.py
+++ b/gitlab/tests/test_gitlabobject.py
@@ -182,7 +182,7 @@ class TestGitLabObject(unittest.TestCase):
def test_get_list_or_object_cant_get(self):
with HTTMock(resp_get_issue):
- gl_object = Issue(self.gl, data={"name": "name"})
+ gl_object = UserProject(self.gl, data={"name": "name"})
self.assertRaises(NotImplementedError,
gl_object._get_list_or_object,
self.gl, id=1)
@@ -245,7 +245,7 @@ class TestGitLabObject(unittest.TestCase):
"password": "password", "id": 1,
"username": "username"})
self.assertEqual(obj.name, "testname")
- obj._created = True
+ obj._from_api = True
obj.name = "newname"
with HTTMock(resp_update_user):
obj.save()
@@ -259,7 +259,7 @@ class TestGitLabObject(unittest.TestCase):
def test_delete(self):
obj = Group(self.gl, data={"name": "testname", "id": 1})
- obj._created = True
+ obj._from_api = True
with HTTMock(resp_delete_group):
data = obj.delete()
self.assertIs(data, True)