| author | ymh <ymh.work@gmail.com> |
| Mon, 13 Jun 2016 14:23:58 +0200 | |
| changeset 613 | e00a24b711a0 |
| parent 610 | b9edc1c1538a |
| child 615 | f3875fbe206a |
| permissions | -rw-r--r-- |
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
1 |
import json |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
2 |
|
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
3 |
from django.contrib.auth import get_user_model |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
4 |
from django.core.urlresolvers import reverse |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
5 |
from renkanmanager.models import Renkan, Revision |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
6 |
from rest_framework import status |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
7 |
from rest_framework.test import APITestCase |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
8 |
|
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
9 |
|
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
10 |
User = get_user_model() |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
11 |
|
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
12 |
class RevisionTests(APITestCase): |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
13 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
14 |
def setUp(self): |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
15 |
User.objects.create_superuser("blop", "blop@blop.com", "blop") |
|
593
2ff785d7026c
corrected tests and serializer so they can support custom user model, added a readme (to be expanded) with configuration information for the field renkan api will use to render user information
durandn
parents:
590
diff
changeset
|
16 |
self.user = User.objects.get_by_natural_key(username="blop") |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
17 |
_ = self.client.login(username="blop", password="blop") |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
18 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
19 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
20 |
# POSTing new Renkan |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
21 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
22 |
|
| 590 | 23 |
post_url = reverse("v1.0:renkan_list") |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
24 |
self.test_title = "test_title_1" |
|
610
b9edc1c1538a
reworked views and serializers to pass and take into account the "validation timestamp" to the model + refactored models to have a content validation method + adapted tests
durandn
parents:
593
diff
changeset
|
25 |
test_content_dict_init = { |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
26 |
"id": "", |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
27 |
"title": "test_title_1", |
|
610
b9edc1c1538a
reworked views and serializers to pass and take into account the "validation timestamp" to the model + refactored models to have a content validation method + adapted tests
durandn
parents:
593
diff
changeset
|
28 |
"description": "", |
|
b9edc1c1538a
reworked views and serializers to pass and take into account the "validation timestamp" to the model + refactored models to have a content validation method + adapted tests
durandn
parents:
593
diff
changeset
|
29 |
"created": "2016-03-11 15:10:10.645193+00:00", |
|
b9edc1c1538a
reworked views and serializers to pass and take into account the "validation timestamp" to the model + refactored models to have a content validation method + adapted tests
durandn
parents:
593
diff
changeset
|
30 |
"updated": "2016-03-11 15:10:10.645193+00:00", |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
31 |
"edges": [], |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
32 |
"nodes": [], |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
33 |
"users": [], |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
34 |
"space_id": "", |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
35 |
"views": [] |
|
610
b9edc1c1538a
reworked views and serializers to pass and take into account the "validation timestamp" to the model + refactored models to have a content validation method + adapted tests
durandn
parents:
593
diff
changeset
|
36 |
} |
|
b9edc1c1538a
reworked views and serializers to pass and take into account the "validation timestamp" to the model + refactored models to have a content validation method + adapted tests
durandn
parents:
593
diff
changeset
|
37 |
self.test_content = json.dumps(test_content_dict_init) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
38 |
self.test_data = {"title": self.test_title, "content": self.test_content} |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
39 |
post_response = self.client.post(post_url, self.test_data, format="json") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
40 |
post_response_dict = json.loads(post_response.content.decode()) |
|
610
b9edc1c1538a
reworked views and serializers to pass and take into account the "validation timestamp" to the model + refactored models to have a content validation method + adapted tests
durandn
parents:
593
diff
changeset
|
41 |
self.test_content_dict = json.loads(post_response_dict.get("content", "{}")) |
|
b9edc1c1538a
reworked views and serializers to pass and take into account the "validation timestamp" to the model + refactored models to have a content validation method + adapted tests
durandn
parents:
593
diff
changeset
|
42 |
self.post_response_content_dict = json.loads(post_response_dict.get("content", "{}")) |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
43 |
self.test_renkan_guid = post_response_dict.get("id", "") |
|
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
44 |
self.test_initial_revision_guid = post_response_dict.get("current_revision_id", "") |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
45 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
46 |
def test_get_revision(self): |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
47 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
48 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
49 |
# GETting revision |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
50 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
51 |
|
| 590 | 52 |
get_url = reverse("v1.0:revision_detail", kwargs={"renkan_guid" : self.test_renkan_guid, "revision_guid": self.test_initial_revision_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
53 |
get_response = self.client.get(get_url, {}, format="json") |
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
54 |
self.assertEqual(get_response.status_code, status.HTTP_200_OK) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
55 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
56 |
# Checking data |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
57 |
get_response_dict = json.loads(get_response.content.decode()) |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
58 |
self.assertEqual(get_response_dict.get("id", ""), self.test_initial_revision_guid) |
|
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
59 |
self.assertEqual(get_response_dict.get("parent_renkan_id", ""), self.test_renkan_guid) |
|
593
2ff785d7026c
corrected tests and serializer so they can support custom user model, added a readme (to be expanded) with configuration information for the field renkan api will use to render user information
durandn
parents:
590
diff
changeset
|
60 |
self.assertEqual(get_response_dict.get("revision_created_by", ""), getattr(self.user, User.USERNAME_FIELD)) |
|
2ff785d7026c
corrected tests and serializer so they can support custom user model, added a readme (to be expanded) with configuration information for the field renkan api will use to render user information
durandn
parents:
590
diff
changeset
|
61 |
self.assertEqual(get_response_dict.get("revision_last_updated_by", ""), getattr(self.user, User.USERNAME_FIELD)) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
62 |
self.assertEqual(get_response_dict.get("title", ""), self.test_data.get("title", "")) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
63 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
64 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
65 |
# GETting with wrong renkan guid |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
66 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
67 |
|
| 590 | 68 |
get_url = reverse("v1.0:revision_detail", kwargs={"renkan_guid" : "bad-renkan-guid", "revision_guid": self.test_initial_revision_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
69 |
get_response = self.client.get(get_url, {}, format="json") |
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
70 |
self.assertEqual(get_response.status_code, status.HTTP_404_NOT_FOUND) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
71 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
72 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
73 |
# GETting with wrong revision guid |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
74 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
75 |
|
| 590 | 76 |
get_url = reverse("v1.0:revision_detail", kwargs={"renkan_guid" : self.test_renkan_guid, "revision_guid": "bad-revision-guid"}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
77 |
get_response = self.client.get(get_url, {}, format="json") |
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
78 |
self.assertEqual(get_response.status_code, status.HTTP_404_NOT_FOUND) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
79 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
80 |
def test_get_revision_list(self): |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
81 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
82 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
83 |
# PUTting another revision in test renkan |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
84 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
85 |
|
| 590 | 86 |
put_url = reverse("v1.0:renkan_detail", kwargs={"renkan_guid" : self.test_renkan_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
87 |
put_title = "edited_title" |
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
88 |
put_data = { |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
89 |
"title" : put_title, |
|
610
b9edc1c1538a
reworked views and serializers to pass and take into account the "validation timestamp" to the model + refactored models to have a content validation method + adapted tests
durandn
parents:
593
diff
changeset
|
90 |
"validation_timestamp": self.post_response_content_dict.get("updated", ""), |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
91 |
"create_new_revision": True |
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
92 |
} |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
93 |
put_response = self.client.put(put_url, put_data, format="json") |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
94 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
95 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
96 |
# GETting revision lists |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
97 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
98 |
|
| 590 | 99 |
get_url = reverse("v1.0:revision_list", kwargs={"renkan_guid" : self.test_renkan_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
100 |
get_response = self.client.get(get_url, {}, format="json") |
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
101 |
self.assertEqual(get_response.status_code, status.HTTP_200_OK) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
102 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
103 |
# Checking data |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
104 |
get_response_content = json.loads(get_response.content.decode()) # Should be a list |
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
105 |
self.assertTrue(isinstance(get_response_content, list)) |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
106 |
self.assertEqual(len(get_response_content), 2) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
107 |
|
|
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
108 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
109 |
def test_delete_revision(self): |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
110 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
111 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
112 |
# Try to DELETE the initial revision (last revision, should 400) |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
113 |
################################################### |
| 590 | 114 |
delete_url = reverse("v1.0:revision_detail", kwargs={"renkan_guid" : self.test_renkan_guid, "revision_guid": self.test_initial_revision_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
115 |
delete_response = self.client.delete(delete_url, {}, format="json") |
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
116 |
self.assertEqual(delete_response.status_code, status.HTTP_400_BAD_REQUEST) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
117 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
118 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
119 |
# PUTting another revision in test renkan |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
120 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
121 |
|
| 590 | 122 |
put_url = reverse("v1.0:renkan_detail", kwargs={"renkan_guid" : self.test_renkan_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
123 |
put_title = "edited_title" |
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
124 |
put_data = { |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
125 |
"title" : put_title, |
|
610
b9edc1c1538a
reworked views and serializers to pass and take into account the "validation timestamp" to the model + refactored models to have a content validation method + adapted tests
durandn
parents:
593
diff
changeset
|
126 |
"validation_timestamp": self.post_response_content_dict.get("updated", ""), |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
127 |
"create_new_revision": True |
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
128 |
} |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
129 |
put_response = self.client.put(put_url, put_data, format="json") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
130 |
put_response_dict = json.loads(put_response.content.decode()) |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
131 |
added_revision_guid = put_response_dict.get("current_revision_id", "") |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
132 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
133 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
134 |
# Try to DELETE the added revision (current revision, should 400) |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
135 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
136 |
|
| 590 | 137 |
delete_url = reverse("v1.0:revision_detail", kwargs={"renkan_guid" : self.test_renkan_guid, "revision_guid": added_revision_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
138 |
delete_response = self.client.delete(delete_url, {}, format="json") |
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
139 |
self.assertEqual(delete_response.status_code, status.HTTP_400_BAD_REQUEST) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
140 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
141 |
# Restoring rightful user |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
142 |
_ = self.client.login(username="blop", password="blop") |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
143 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
144 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
145 |
# Try to DELETE the initial revision (should 204 now that we added a revision) |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
146 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
147 |
|
| 590 | 148 |
delete_url = reverse("v1.0:revision_detail", kwargs={"renkan_guid" : self.test_renkan_guid, "revision_guid": self.test_initial_revision_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
149 |
delete_response = self.client.delete(delete_url, {}, format="json") |
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
150 |
self.assertEqual(delete_response.status_code, status.HTTP_204_NO_CONTENT) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
151 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
152 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
153 |
# Try to DELETE with wrong renkan guid |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
154 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
155 |
|
| 590 | 156 |
delete_url = reverse("v1.0:revision_detail", kwargs={"renkan_guid" : "bad-renkan-guid", "revision_guid": self.test_initial_revision_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
157 |
delete_response = self.client.delete(delete_url, {}, format="json") |
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
158 |
self.assertEqual(delete_response.status_code, status.HTTP_404_NOT_FOUND) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
159 |
|
|
587
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
160 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
161 |
# Try to DELETE with wrong revision guid |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
162 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
163 |
|
| 590 | 164 |
delete_url = reverse("v1.0:revision_detail", kwargs={"renkan_guid" : self.test_renkan_guid, "revision_guid": "bad-revision-guid"}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
165 |
delete_response = self.client.delete(delete_url, {}, format="json") |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
166 |
self.assertEqual(delete_response.status_code, status.HTTP_404_NOT_FOUND) |