This repository was archived by the owner on Nov 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathtest_projects.py
More file actions
73 lines (60 loc) · 2.3 KB
/
test_projects.py
File metadata and controls
73 lines (60 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import responses
from requests.exceptions import HTTPError
from gitlab_tests.base_test import BaseTest
from response_data.projects import *
class TestDeleteProject(BaseTest):
@responses.activate
def test_delete_project_true(self):
responses.add(
responses.DELETE,
self.gitlab.api_url + '/projects/1',
json=True,
status=200,
content_type='application/json')
self.assertEqual({}, self.gitlab.delete_project(1))
self.assertEqual(True, self.gitlab.deleteproject(1))
@responses.activate
def test_delete_project_json(self):
responses.add(
responses.DELETE,
self.gitlab.api_url + '/projects/1',
json={},
status=200,
content_type='application/json')
self.assertEqual({}, self.gitlab.delete_project(1))
self.assertEqual(True, self.gitlab.deleteproject(1))
@responses.activate
def test_delete_project_exception(self):
responses.add(
responses.DELETE,
self.gitlab.api_url + '/projects/1',
json=delete_project,
status=404,
content_type='application/json')
self.gitlab.suppress_http_error = False
self.assertRaises(HTTPError, self.gitlab.delete_project, 1)
self.gitlab.suppress_http_error = True
self.assertEqual(True, self.gitlab.deleteproject(1))
class TestGetProject(BaseTest):
@responses.activate
def test_delete_project_true(self):
responses.add(
responses.GET,
self.gitlab.api_url + '/projects/1',
json=get_project,
status=200,
content_type='application/json')
self.assertEqual(get_project, self.gitlab.get_project(1))
self.assertEqual(get_project, self.gitlab.getproject(1))
@responses.activate
def test_delete_project_json(self):
responses.add(
responses.GET,
self.gitlab.api_url + '/projects/1',
body='{"error": "Not found"}',
status=404,
content_type='application/json')
self.gitlab.suppress_http_error = False
self.assertRaises(HTTPError, self.gitlab.get_project, 1)
self.gitlab.suppress_http_error = True
self.assertFalse(self.gitlab.getproject(1))