Skip to content

Commit f33c316

Browse files
authored
Merge pull request #59 from contentstack/next
Added testcases for roles creation with taxonomy permission
2 parents 0837c32 + f37f177 commit f33c316

File tree

6 files changed

+158
-2
lines changed

6 files changed

+158
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
## Content Management SDK For Python
44
---
55

6+
## v1.2.0
7+
8+
#### Date: 08 July 2024
9+
10+
- Added testcases for creation of Roles with taxonomy permission.
11+
---
12+
613
## v1.1.1
714

815
#### Date: 21 May 2024

contentstack_management/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
__author__ = 'ishaileshmishra'
7373
__status__ = 'debug'
7474
__region__ = 'na'
75-
__version__ = '1.1.1'
75+
__version__ = '1.2.0'
7676
__host__ = 'api.contentstack.io'
7777
__protocol__ = 'https://'
7878
__api_version__ = 'v3'

tests/api/roles/test_roles_api.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,27 @@ def test_get_a_roles(self):
2828
f"{self.client.endpoint}roles/{role_uid}")
2929
self.assertEqual(response.status_code, 200)
3030

31+
def test_create_taxonomy(self):
32+
data = {
33+
"taxonomy": {
34+
"uid": "taxonomy_testing1",
35+
"name": "taxonomy_testing1",
36+
"description": "Description for Taxonomy 1"
37+
}
38+
}
39+
response = self.client.stack(api_key).taxonomy().create(data)
40+
self.assertEqual(response.status_code, 201)
41+
42+
def test_create_terms(self):
43+
data = {
44+
"term": {
45+
"uid": "term_test1",
46+
"name": "term_test1",
47+
"parent_uid": None
48+
}
49+
}
50+
response = self.client.stack(api_key).taxonomy("taxonomy_1").terms().create(data)
51+
self.assertEqual(response.status_code, 201)
3152

3253
def test_create(self):
3354
data = {
@@ -106,6 +127,36 @@ def test_create(self):
106127
"acl":{
107128
"read":True
108129
}
130+
},
131+
{
132+
"module": "taxonomy",
133+
"taxonomies": ["taxonomy_testing1"],
134+
"terms": ["taxonomy_testing1.term_test1"],
135+
"content_types": [
136+
{
137+
"uid": "$all",
138+
"acl": {
139+
"read": True,
140+
"sub_acl": {
141+
"read": True,
142+
"create": True,
143+
"update": True,
144+
"delete": True,
145+
"publish": True
146+
}
147+
}
148+
}
149+
],
150+
"acl": {
151+
"read": True,
152+
"sub_acl": {
153+
"read": True,
154+
"create": True,
155+
"update": True,
156+
"delete": True,
157+
"publish": True
158+
}
159+
}
109160
}
110161
]
111162
}
@@ -207,6 +258,14 @@ def test_update_roles(self):
207258
self.assertEqual(response.request.url,
208259
f"{self.client.endpoint}roles/{role_uid}")
209260
self.assertEqual(response.status_code, 200)
261+
262+
def test_delete(self):
263+
response = self.client.stack(api_key).taxonomy("taxonomy_testing1").terms("term_test1").delete()
264+
self.assertEqual(response.status_code, 200)
265+
266+
def test_delete_taxonomy(self):
267+
response = self.client.stack(api_key).taxonomy("taxonomy_testing1").delete()
268+
self.assertEqual(response.status_code, 200)
210269

211270

212271
def test_delete_roles(self):

tests/mock/roles/test_roles_mock.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,36 @@ def test_create(self):
119119
"acl":{
120120
"read":True
121121
}
122+
},
123+
{
124+
"module": "taxonomy",
125+
"taxonomies": ["taxonomy_testing1"],
126+
"terms": ["taxonomy_testing1.term_test1"],
127+
"content_types": [
128+
{
129+
"uid": "$all",
130+
"acl": {
131+
"read": True,
132+
"sub_acl": {
133+
"read": True,
134+
"create": True,
135+
"update": True,
136+
"delete": True,
137+
"publish": True
138+
}
139+
}
140+
}
141+
],
142+
"acl": {
143+
"read": True,
144+
"sub_acl": {
145+
"read": True,
146+
"create": True,
147+
"update": True,
148+
"delete": True,
149+
"publish": True
150+
}
151+
}
122152
}
123153
]
124154
}

tests/resources/mock_roles/create.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,37 @@
7575
"acl": {
7676
"read": true
7777
}
78-
}
78+
},
79+
{
80+
"module": "taxonomy",
81+
"taxonomies": ["taxonomy_testing1"],
82+
"terms": ["taxonomy_testing1.term_test1"],
83+
"content_types": [
84+
{
85+
"uid": "$all",
86+
"acl": {
87+
"read": true,
88+
"sub_acl": {
89+
"read": true,
90+
"create": true,
91+
"update": true,
92+
"delete": true,
93+
"publish": true
94+
}
95+
}
96+
}
97+
],
98+
"acl": {
99+
"read": true,
100+
"sub_acl": {
101+
"read": true,
102+
"create": true,
103+
"update": true,
104+
"delete": true,
105+
"publish": true
106+
}
107+
}
108+
}
79109
],
80110
"users": [],
81111
"uid": "role_uid",

tests/unit/roles/test_roles_unit.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,36 @@ def test_create(self):
109109
"acl":{
110110
"read":True
111111
}
112+
},
113+
{
114+
"module": "taxonomy",
115+
"taxonomies": ["taxonomy_testing1"],
116+
"terms": ["taxonomy_testing1.term_test1"],
117+
"content_types": [
118+
{
119+
"uid": "$all",
120+
"acl": {
121+
"read": True,
122+
"sub_acl": {
123+
"read": True,
124+
"create": True,
125+
"update": True,
126+
"delete": True,
127+
"publish": True
128+
}
129+
}
130+
}
131+
],
132+
"acl": {
133+
"read": True,
134+
"sub_acl": {
135+
"read": True,
136+
"create": True,
137+
"update": True,
138+
"delete": True,
139+
"publish": True
140+
}
141+
}
112142
}
113143
]
114144
}

0 commit comments

Comments
 (0)