| author | ymh <ymh.work@gmail.com> |
| Mon, 20 Jun 2016 14:44:40 +0200 | |
| changeset 615 | f3875fbe206a |
| parent 613 | e00a24b711a0 |
| child 618 | 3051b847c124 |
| 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 |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
8 |
from rest_framework.test import force_authenticate |
|
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
|
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 |
|
|
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 |
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
|
12 |
|
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
13 |
class RenkanTests(APITestCase): |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
14 |
|
|
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
|
15 |
def setUp(self): |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
16 |
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
|
17 |
self.user = User.objects.get_by_natural_key(username="blop") |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
18 |
|
|
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
19 |
self.client.force_login(self.user) |
|
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
20 |
|
|
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
|
21 |
# POSTing test workspace |
| 590 | 22 |
post_url = reverse("v1.0:workspace_list") |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
23 |
test_title = "bleh_title" |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
24 |
data = {"title": test_title} |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
25 |
post_response = self.client.post(post_url, data, format="json") |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
26 |
self.test_workspace_guid = json.loads(post_response.content.decode()).get("id") |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
27 |
self.first_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
|
28 |
self.first_test_content_dict = { |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
29 |
"id": "", |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
30 |
"title": "test_title_1", |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
31 |
"description": "test_description_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
|
32 |
"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
|
33 |
"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
|
34 |
"edges": [], |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
35 |
"nodes": [], |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
36 |
"users": [], |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
37 |
"space_id": "", |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
38 |
"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
|
39 |
} |
|
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
|
40 |
self.first_test_content = json.dumps(self.first_test_content_dict) |
|
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.second_test_title = "test_title_2" |
|
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.second_test_content_dict = { |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
43 |
"id": "", |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
44 |
"title": "test_title_2", |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
45 |
"description": "test_description_2", |
|
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
|
46 |
"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
|
47 |
"updated": "2016-03-12 15:10:10.645193+00:00", |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
48 |
"edges": [], |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
49 |
"nodes": [], |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
50 |
"users": [], |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
51 |
"space_id": "", |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
52 |
"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
|
53 |
} |
|
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
|
54 |
self.second_test_content = json.dumps(self.second_test_content_dict) |
|
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
|
55 |
self.third_test_title = "test_title_3" |
|
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
|
56 |
self.third_test_content_dict = { |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
57 |
"id": "", |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
58 |
"title": "test_title_3", |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
59 |
"description": "test_description_3", |
|
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
|
60 |
"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
|
61 |
"updated": "2016-03-13 15:10:10.645193+00:00", |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
62 |
"edges": [], |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
63 |
"nodes": [], |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
64 |
"users": [], |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
65 |
"space_id": "", |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
66 |
"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
|
67 |
} |
|
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
|
68 |
self.third_test_content = json.dumps(self.third_test_content_dict) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
69 |
|
|
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 |
def test_create_renkan(self): |
|
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 |
# 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
|
74 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
75 |
|
| 590 | 76 |
post_url = reverse("v1.0:renkan_list") |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
77 |
data = {"title": self.first_test_title, "content": self.first_test_content} |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
78 |
|
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
79 |
post_response = self.client.post(post_url, data, 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
|
80 |
self.assertEqual(post_response.status_code, status.HTTP_201_CREATED) |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
81 |
self.assertEqual(Renkan.objects.count(), 1) |
|
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 |
self.assertEqual(Revision.objects.count(), 1) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
83 |
|
|
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
|
84 |
# Checking POSTed Renkan data |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
85 |
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
|
86 |
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
|
87 |
new_renkan_guid = post_response_dict.get("id", "") |
|
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 |
new_renkan = Renkan.objects.get(renkan_guid=new_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
|
89 |
# GUIDs and username |
|
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
|
90 |
self.assertEqual(getattr(self.user, User.USERNAME_FIELD), post_response_dict.get("created_by", "")) |
|
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
|
91 |
self.assertEqual(getattr(self.user, User.USERNAME_FIELD), post_response_dict.get("last_updated_by", "")) |
|
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
|
92 |
self.assertEqual(getattr(self.user, User.USERNAME_FIELD), getattr(new_renkan.creator, User.USERNAME_FIELD)) |
|
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
|
93 |
# Content and title extracted from revision |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
94 |
self.assertEqual(new_renkan.title, self.first_test_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
|
95 |
new_renkan_content_dict = json.loads(new_renkan.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
|
96 |
for key in list(self.first_test_content_dict.keys()) + list(set(new_renkan_content_dict.keys()) - set(self.first_test_content_dict.keys())): |
|
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
|
97 |
if key != "updated" and key != "created" and key != "id": |
|
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
|
98 |
self.assertEqual(new_renkan_content_dict.get(key, ""), self.first_test_content_dict.get(key, "")) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
99 |
|
|
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
|
100 |
# Revision count |
|
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(new_renkan.revision_count, 1) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
102 |
self.assertEqual(post_response_dict.get("revision_count", ""), 1) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
103 |
|
|
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
|
104 |
# Checking POSTed Renkan revision data |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
105 |
new_renkan_revision_guid = post_response_dict.get("current_revision_id", "") |
|
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
|
106 |
new_renkan_revision = Revision.objects.get(revision_guid = new_renkan_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
|
107 |
# GUIDs and username |
|
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
|
108 |
self.assertEqual(getattr(self.user, User.USERNAME_FIELD), getattr(new_renkan_revision.creator, 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
|
109 |
self.assertEqual(getattr(self.user, User.USERNAME_FIELD), getattr(new_renkan_revision.last_updated_by, User.USERNAME_FIELD)) |
|
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
|
110 |
# Title and content |
|
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 |
# in the response |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
112 |
self.assertEqual(post_response_dict.get("title", ""), self.first_test_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
|
113 |
for key in list(self.first_test_content_dict.keys()) + list(set(post_response_content_dict.keys()) - set(self.first_test_content_dict.keys())): |
|
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
|
114 |
if key != "updated" and key != "created" and key != "id": |
|
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
|
115 |
self.assertEqual(post_response_content_dict.get(key, ""), self.first_test_content_dict.get(key, "")) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
116 |
|
|
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
|
117 |
# in the database |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
118 |
self.assertEqual(new_renkan_revision.title, self.first_test_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
|
119 |
new_revision_content_dict = json.loads(new_renkan_revision.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
|
120 |
for key in list(self.first_test_content_dict.keys()) + list(set(new_revision_content_dict.keys()) - set(self.first_test_content_dict.keys())): |
|
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
|
121 |
if key != "updated" and key != "created" and key != "id": |
|
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
|
122 |
self.assertEqual(new_revision_content_dict.get(key, ""), self.first_test_content_dict.get(key, "")) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
123 |
|
|
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 |
# Checking permission |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
125 |
self.assertTrue(self.user.has_perm("view_renkan", new_renkan)) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
126 |
|
|
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
|
127 |
################################################### |
|
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 |
# POSTing new Renkan into workspace |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
129 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
130 |
|
| 590 | 131 |
post_url = reverse("v1.0:renkan_list_workspace", kwargs={"workspace_guid": self.test_workspace_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
132 |
data = {"title": self.second_test_title, "content": self.second_test_content} |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
133 |
|
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
134 |
post_response = self.client.post(post_url, data, 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
|
135 |
self.assertEqual(post_response.status_code, status.HTTP_201_CREATED) |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
136 |
self.assertEqual(Renkan.objects.count(), 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
|
137 |
self.assertEqual(Revision.objects.count(), 2) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
138 |
|
|
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 |
# Checking POSTed Renkan data |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
140 |
post_response_dict = json.loads(post_response.content.decode()) |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
141 |
new_renkan_guid = post_response_dict.get("id", "") |
|
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
|
142 |
new_renkan = Renkan.objects.get(renkan_guid=new_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
|
143 |
# GUIDs and username |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
144 |
self.assertEqual(self.test_workspace_guid, post_response_dict.get("workspace_id", "")) |
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
145 |
self.assertEqual(self.test_workspace_guid, str(new_renkan.workspace.workspace_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
|
146 |
self.assertEqual(getattr(self.user, User.USERNAME_FIELD), post_response_dict.get("created_by", "")) |
|
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
|
147 |
self.assertEqual(getattr(self.user, User.USERNAME_FIELD), post_response_dict.get("last_updated_by", "")) |
|
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
|
148 |
self.assertEqual(getattr(self.user, User.USERNAME_FIELD), getattr(new_renkan.creator, User.USERNAME_FIELD)) |
|
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
|
149 |
# Content and title extracted from revision |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
150 |
self.assertEqual(new_renkan.title, self.second_test_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
|
151 |
new_renkan_content_dict = json.loads(new_renkan.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
|
152 |
for key in list(self.second_test_content_dict.keys()) + list(set(new_renkan_content_dict.keys()) - set(self.second_test_content_dict.keys())): |
|
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
|
153 |
if key != "updated" and key != "created" and key != "id" and key != "space_id": |
|
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
|
154 |
self.assertEqual(new_renkan_content_dict.get(key, ""), self.second_test_content_dict.get(key, "")) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
155 |
|
|
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
|
156 |
# Revision count |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
157 |
self.assertEqual(new_renkan.revision_count, 1) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
158 |
self.assertEqual(post_response_dict.get("revision_count", ""), 1) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
159 |
|
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
160 |
################################################### |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
161 |
# POSTing new Renkan with no content |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
162 |
################################################### |
| 590 | 163 |
post_url = reverse("v1.0:renkan_list_workspace", kwargs={"workspace_guid": self.test_workspace_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
164 |
test_title = "bleh_title_2" |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
165 |
data = {"title": test_title} |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
166 |
post_response = self.client.post(post_url, data, format="json") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
167 |
self.assertEqual(post_response.status_code, status.HTTP_201_CREATED) |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
168 |
self.assertEqual(Renkan.objects.count(), 3) |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
169 |
self.assertEqual(Revision.objects.count(), 3) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
170 |
|
|
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
|
171 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
172 |
# POSTing with wrong workspace_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
|
173 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
174 |
|
| 590 | 175 |
post_url = reverse("v1.0:renkan_list_workspace", kwargs={"workspace_guid": "bleh-bad-workspace-guid"}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
176 |
data = {"title": self.third_test_title, "content": self.third_test_content} |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
177 |
|
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
178 |
post_response = self.client.post(post_url, data, format="json") |
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
179 |
self.assertEqual(post_response.status_code, status.HTTP_400_BAD_REQUEST) |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
180 |
|
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
181 |
################################################### |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
182 |
# POSTing with wrong workspace_guid |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
183 |
################################################### |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
184 |
|
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
185 |
post_url = reverse("v1.0:renkan_list_workspace", kwargs={"workspace_guid": "00000000-0000-0000-0000-000000000000"}) |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
186 |
data = {"title": self.third_test_title, "content": self.third_test_content} |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
187 |
|
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
188 |
post_response = self.client.post(post_url, data, 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
|
189 |
self.assertEqual(post_response.status_code, status.HTTP_404_NOT_FOUND) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
190 |
|
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
191 |
|
|
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
|
192 |
################################################### |
|
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
|
193 |
# POSTing with non-JSON serializable 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
|
194 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
195 |
|
|
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
|
196 |
post_url = reverse("v1.0:renkan_list") |
|
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
|
197 |
data = {"title": self.third_test_title, "content": "notJson(Serializable}"} |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
198 |
|
|
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
|
199 |
post_response = self.client.post(post_url, data, format="json") |
|
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
|
200 |
self.assertEqual(post_response.status_code, status.HTTP_400_BAD_REQUEST) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
201 |
|
|
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
202 |
|
|
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
|
203 |
def test_get_renkan(self): |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
204 |
|
|
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
|
205 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
206 |
# 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
|
207 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
208 |
|
| 590 | 209 |
post_url = reverse("v1.0:renkan_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
|
210 |
data = {} |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
211 |
post_response = self.client.post(post_url, data, format="json") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
212 |
post_response_dict = json.loads(post_response.content.decode()) |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
213 |
new_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
|
214 |
new_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
|
215 |
|
|
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
|
216 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
217 |
# GETting posted 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
|
218 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
219 |
|
| 590 | 220 |
get_url = reverse("v1.0:renkan_detail", kwargs={"renkan_guid":new_renkan_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
221 |
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
|
222 |
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
|
223 |
|
|
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
|
224 |
# Checking GET data |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
225 |
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
|
226 |
self.assertEqual(new_renkan_guid, get_response_dict.get("id", "")) |
|
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
227 |
self.assertEqual(new_revision_guid, get_response_dict.get("current_revision_id", "")) |
|
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
|
228 |
self.assertEqual(getattr(self.user, User.USERNAME_FIELD), get_response_dict.get("created_by", "")) |
|
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
|
229 |
self.assertEqual(getattr(self.user, User.USERNAME_FIELD), get_response_dict.get("last_updated_by", "")) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
230 |
|
|
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
|
231 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
232 |
# GETting with wrong 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
|
233 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
234 |
|
| 590 | 235 |
get_url = reverse("v1.0:renkan_detail", kwargs={"renkan_guid": "bad-id"}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
236 |
get_response = self.client.get(get_url, format="json") |
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
237 |
self.assertEqual(get_response.status_code, status.HTTP_400_BAD_REQUEST) |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
238 |
|
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
239 |
################################################### |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
240 |
# GETting with wrong guid |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
241 |
################################################### |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
242 |
|
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
243 |
get_url = reverse("v1.0:renkan_detail", kwargs={"renkan_guid": "00000000-0000-0000-0000-000000000000"}) |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
244 |
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
|
245 |
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
|
246 |
|
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
247 |
|
|
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
|
248 |
def test_get_renkan_list(self): |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
249 |
|
|
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
|
250 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
251 |
# POSTing new Renkans |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
252 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
253 |
|
| 590 | 254 |
post_url = reverse("v1.0:renkan_list") |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
255 |
first_data = {"title": self.first_test_title, "content": self.first_test_content} |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
256 |
second_data = {"title": self.second_test_title, "content": self.second_test_content} |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
257 |
self.client.post(post_url, first_data, format="json") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
258 |
self.client.post(post_url, second_data, format="json") |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
259 |
|
|
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
|
260 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
261 |
# GETting posted Renkans |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
262 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
263 |
|
|
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
|
264 |
get_url = post_url |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
265 |
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
|
266 |
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
|
267 |
|
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
268 |
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
|
269 |
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
|
270 |
self.assertEqual(len(get_response_content), 2) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
271 |
|
|
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
|
272 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
273 |
# POSTing new Renkan into workspace |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
274 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
275 |
|
| 590 | 276 |
post_url = reverse("v1.0:renkan_list_workspace", kwargs={"workspace_guid": self.test_workspace_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
277 |
third_data = {"title": self.third_test_title, "content": self.third_test_content} |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
278 |
self.client.post(post_url, third_data, format="json") |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
279 |
|
|
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
|
280 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
281 |
# GETting posted Renkans |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
282 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
283 |
|
|
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
|
284 |
get_url = post_url |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
285 |
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
|
286 |
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
|
287 |
|
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
288 |
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
|
289 |
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
|
290 |
self.assertEqual(len(get_response_content), 1) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
291 |
|
|
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
292 |
|
|
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
293 |
|
|
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
294 |
|
|
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
295 |
|
|
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
|
296 |
def test_update_renkan(self): |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
297 |
|
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
298 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
299 |
# 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
|
300 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
301 |
|
| 590 | 302 |
post_url = reverse("v1.0:renkan_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
|
303 |
data = {} |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
304 |
post_response = self.client.post(post_url, data, format="json") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
305 |
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
|
306 |
post_response_ts = json.loads(post_response_dict.get("content"), "{}").get("updated", "") |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
307 |
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
|
308 |
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
|
309 |
|
|
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
|
310 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
311 |
# PUTting by updating current 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
|
312 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
313 |
|
| 590 | 314 |
put_url = reverse("v1.0:renkan_detail", kwargs={"renkan_guid": renkan_guid}) |
|
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
|
315 |
put_content_dict = json.loads(self.first_test_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
|
316 |
put_content_dict["updated"] = post_response_ts |
|
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
|
317 |
put_data = { |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
318 |
"title" : self.first_test_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
|
319 |
"content" : json.dumps(put_content_dict), |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
320 |
"create_new_revision": False |
|
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
|
321 |
} |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
322 |
put_response = self.client.put(put_url, put_data, format="json") |
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
323 |
self.assertEqual(put_response.status_code, status.HTTP_200_OK, "response is %r"%put_response.content) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
324 |
put_response_dict = json.loads(put_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
|
325 |
put_response_content_dict = json.loads(put_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
|
326 |
put_response_ts = put_response_content_dict.get("updated", "") |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
327 |
|
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
328 |
# checking we"re still on the same revision as the initial one |
|
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
|
329 |
updated_project = Renkan.objects.get(renkan_guid=renkan_guid) |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
330 |
self.assertEqual(revision_guid, put_response_dict.get("current_revision_id", "")) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
331 |
self.assertEqual(put_response_dict.get("revision_count", ""), 1) |
|
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
|
332 |
self.assertEqual(updated_project.revision_count, 1) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
333 |
|
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
334 |
self.assertEqual(revision_guid, str(updated_project.current_revision.revision_guid)) |
|
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
|
335 |
# checking data was updated |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
336 |
# in the reponse |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
337 |
self.assertEqual(put_response_dict.get("title", ""), self.first_test_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
|
338 |
for key in list(self.first_test_content_dict.keys()) + list(set(put_response_content_dict.keys()) - set(self.first_test_content_dict.keys())): |
|
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
|
339 |
if key != "updated" and key!= "id" and key != "space_id": |
|
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
|
340 |
self.assertEqual(put_response_content_dict.get(key, ""), self.first_test_content_dict.get(key, "")) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
341 |
|
|
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
|
342 |
# in the database |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
343 |
updated_revision = Revision.objects.get(revision_guid=revision_guid) |
|
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
|
344 |
updated_revision_content_dict = json.loads(updated_revision.content) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
345 |
self.assertEqual(updated_revision.title, self.first_test_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
|
346 |
for key in list(self.first_test_content_dict.keys()) + list(set(updated_revision_content_dict.keys()) - set(self.first_test_content_dict.keys())): |
|
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
|
347 |
if key != "updated" and key!= "id" and key != "space_id": |
|
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
|
348 |
self.assertEqual(updated_revision_content_dict.get(key, ""), self.first_test_content_dict.get(key, "")) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
349 |
|
|
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
|
350 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
351 |
# PUTting by creating a new 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
|
352 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
353 |
|
|
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
|
354 |
put_content_dict = json.loads(self.second_test_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
|
355 |
put_content_dict["updated"] = put_response_ts |
|
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
|
356 |
put_data = { |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
357 |
"title" : self.second_test_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
|
358 |
"content" : json.dumps(put_content_dict), |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
359 |
"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
|
360 |
} |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
361 |
put_response = self.client.put(put_url, put_data, format="json") |
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
362 |
self.assertEqual(put_response.status_code, status.HTTP_200_OK, "response is %r"%put_response.content) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
363 |
put_response_dict = json.loads(put_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
|
364 |
put_response_content_dict = json.loads(put_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
|
365 |
put_response_ts = put_response_content_dict.get("updated", "") |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
366 |
|
|
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
|
367 |
# checking we created a new 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
|
368 |
updated_project = Renkan.objects.get(renkan_guid=renkan_guid) |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
369 |
created_revision_guid = put_response_dict.get("current_revision_id", "") |
|
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
|
370 |
self.assertNotEqual(created_revision_guid, 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
|
371 |
self.assertEqual(Renkan.objects.count(), 1) |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
372 |
self.assertEqual(Revision.objects.count(), 2) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
373 |
self.assertEqual(put_response_dict.get("revision_count", ""), 2) |
|
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
|
374 |
self.assertEqual(updated_project.revision_count, 2) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
375 |
|
|
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
|
376 |
# checking project now points towards new revision |
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
377 |
self.assertEqual(str(updated_project.current_revision.revision_guid), created_revision_guid) |
|
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
|
378 |
# checking data was updated |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
379 |
# in the reponse |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
380 |
self.assertEqual(put_response_dict.get("title", ""), self.second_test_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
|
381 |
for key in list(self.second_test_content_dict.keys()) + list(set(put_response_content_dict.keys()) - set(self.second_test_content_dict.keys())): |
|
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
|
382 |
if key != "updated" and key!= "id" and key != "space_id": |
|
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
|
383 |
self.assertEqual(put_response_content_dict.get(key, ""), self.second_test_content_dict.get(key, "")) |
|
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
|
384 |
# in the database |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
385 |
updated_revision = Revision.objects.get(revision_guid=created_revision_guid) |
|
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
|
386 |
updated_revision_content_dict = json.loads(updated_revision.content) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
387 |
self.assertEqual(updated_revision.title, self.second_test_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
|
388 |
for key in list(self.second_test_content_dict.keys()) + list(set(updated_revision_content_dict.keys()) - set(self.second_test_content_dict.keys())): |
|
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
|
389 |
if key != "updated" and key!= "id" and key != "space_id": |
|
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
|
390 |
self.assertEqual(updated_revision_content_dict.get(key, ""), self.second_test_content_dict.get(key, "")) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
391 |
|
|
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
|
392 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
393 |
# try to update source_revision_guid or workspace_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
|
394 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
395 |
|
|
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
|
396 |
put_data = { |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
397 |
"title" : self.third_test_title, |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
398 |
"content" : self.third_test_content, |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
399 |
"workspace_id": "bleh-workspace-guid" # should fail without even checking the id |
|
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
|
400 |
} |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
401 |
put_response = self.client.put(put_url, put_data, 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
|
402 |
self.assertEqual(put_response.status_code, status.HTTP_400_BAD_REQUEST) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
403 |
|
|
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
|
404 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
405 |
# PUTting with wrong 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
|
406 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
407 |
|
| 590 | 408 |
put_url = reverse("v1.0:renkan_detail", kwargs={"renkan_guid": "bad-id"}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
409 |
put_response = self.client.put(put_url, {}, format="json") |
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
410 |
self.assertEqual(put_response.status_code, status.HTTP_400_BAD_REQUEST) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
411 |
|
|
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
412 |
|
|
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
|
413 |
def test_copy_renkan(self): |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
414 |
|
|
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
|
415 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
416 |
# 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
|
417 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
418 |
|
| 590 | 419 |
post_url = reverse("v1.0:renkan_list") |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
420 |
data = {"title": self.first_test_title, "content": self.first_test_content} |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
421 |
post_response = self.client.post(post_url, data, format="json") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
422 |
post_response_dict = json.loads(post_response.content.decode()) |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
423 |
source_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
|
424 |
source_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
|
425 |
|
|
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
|
426 |
################################################### |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
427 |
# POSTing copy with query arg for RENKAN guid |
|
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
|
428 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
429 |
|
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
430 |
first_copy_data = {"title": "new_title_copy_1"} |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
431 |
first_copy_url = post_url+"?source_renkan_id="+source_renkan_guid |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
432 |
first_copy_response = self.client.post(first_copy_url, first_copy_data, format="json") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
433 |
first_copy_response_dict = json.loads(first_copy_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
|
434 |
first_copy_response_content_dict = json.loads(first_copy_response_dict.get("content", "{}")) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
435 |
self.assertEqual(first_copy_response.status_code, status.HTTP_201_CREATED) |
|
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
|
436 |
self.assertEqual(Renkan.objects.count(), 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
|
437 |
# Checking data |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
438 |
# in the response |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
439 |
self.assertNotEqual(first_copy_response_dict.get("id"), source_renkan_guid) |
|
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
440 |
self.assertEqual(first_copy_response_dict.get("source_revision_id"), source_revision_guid) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
441 |
self.assertEqual(first_copy_response_dict.get("title", ""), "new_title_copy_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
|
442 |
for key in list(self.first_test_content_dict.keys()) + list(set(first_copy_response_content_dict.keys()) - set(self.first_test_content_dict.keys())): |
|
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
|
443 |
if key != "updated" and key != "created" and key !="title" and key!= "id" and key != "space_id": |
|
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
|
444 |
self.assertEqual(first_copy_response_content_dict.get(key, ""), self.first_test_content_dict.get(key, "")) |
|
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
|
445 |
self.assertEqual(first_copy_response_dict.get("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
|
446 |
self.assertEqual(first_copy_response_dict.get("last_updated_by", ""), getattr(self.user, User.USERNAME_FIELD)) |
|
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
|
447 |
# in the database |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
448 |
first_copy = Renkan.objects.get(renkan_guid=first_copy_response_dict.get("id", "")) |
|
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
449 |
first_copy_revision = Revision.objects.get(revision_guid=first_copy_response_dict.get("current_revision_id", "")) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
450 |
self.assertEqual(first_copy.title, "new_title_copy_1") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
451 |
self.assertEqual(first_copy_revision.title, "new_title_copy_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
|
452 |
first_copy_revision_content_dict = json.loads(first_copy_revision.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
|
453 |
for key in list(self.first_test_content_dict.keys()) + list(set(first_copy_revision_content_dict.keys()) - set(self.first_test_content_dict.keys())): |
|
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
|
454 |
if key != "updated" and key != "created" and key!= "id" and key != "space_id": |
|
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
|
455 |
self.assertEqual(first_copy_revision_content_dict.get(key, ""), self.first_test_content_dict.get(key, "")) |
|
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
|
456 |
self.assertEqual(getattr(first_copy.creator, User.USERNAME_FIELD), 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
|
457 |
self.assertEqual(getattr(first_copy_revision.creator, User.USERNAME_FIELD), 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
|
458 |
self.assertEqual(getattr(first_copy_revision.last_updated_by, User.USERNAME_FIELD), getattr(self.user, User.USERNAME_FIELD)) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
459 |
|
|
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
|
460 |
################################################### |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
461 |
# POSTing copy with source_renkan_guid in data |
|
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
|
462 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
463 |
|
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
464 |
second_copy_data = {"source_renkan_id": source_renkan_guid, "title": "new_title_copy_2"} |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
465 |
second_copy_url = post_url |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
466 |
second_copy_response = self.client.post(second_copy_url, second_copy_data, format="json") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
467 |
second_copy_response_dict = json.loads(second_copy_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
|
468 |
second_copy__response_content_dict = json.loads(second_copy_response_dict.get("content", "{}")) |
|
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
|
469 |
self.assertEqual(second_copy_response.status_code, status.HTTP_201_CREATED) |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
470 |
self.assertEqual(Renkan.objects.count(), 3) |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
471 |
# Checking data |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
472 |
# in the response |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
473 |
self.assertNotEqual(second_copy_response_dict.get("id"), source_renkan_guid) |
|
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
474 |
self.assertEqual(second_copy_response_dict.get("source_revision_id"), source_revision_guid) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
475 |
self.assertEqual(second_copy_response_dict.get("title", ""), "new_title_copy_2") |
|
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
|
476 |
for key in list(self.first_test_content_dict.keys()) + list(set(second_copy__response_content_dict.keys()) - set(self.first_test_content_dict.keys())): |
|
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
|
477 |
if key != "updated" and key != "created" and key!= "id" and key != "space_id": |
|
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
|
478 |
self.assertEqual(second_copy__response_content_dict.get(key, ""), self.first_test_content_dict.get(key, "")) |
|
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
|
479 |
self.assertEqual(second_copy_response_dict.get("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
|
480 |
self.assertEqual(second_copy_response_dict.get("last_updated_by", ""), getattr(self.user, User.USERNAME_FIELD)) |
|
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
|
481 |
# in the database |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
482 |
second_copy = Renkan.objects.get(renkan_guid=second_copy_response_dict.get("id", "")) |
|
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
483 |
second_copy_revision = Revision.objects.get(revision_guid=second_copy_response_dict.get("current_revision_id", "")) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
484 |
self.assertEqual(second_copy.title, "new_title_copy_2") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
485 |
self.assertEqual(second_copy_revision.title, "new_title_copy_2") |
|
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
|
486 |
second_copy_revision_content_dict = json.loads(second_copy_revision.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
|
487 |
for key in list(self.first_test_content_dict.keys()) + list(set(second_copy_revision_content_dict.keys()) - set(self.first_test_content_dict.keys())): |
|
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
|
488 |
if key != "updated" and key != "created" and key!= "id" and key != "space_id": |
|
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
|
489 |
self.assertEqual(second_copy_revision_content_dict.get(key, ""), self.first_test_content_dict.get(key, "")) |
|
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
|
490 |
self.assertEqual(getattr(second_copy.creator, User.USERNAME_FIELD), 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
|
491 |
self.assertEqual(getattr(second_copy_revision.creator, User.USERNAME_FIELD), 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
|
492 |
self.assertEqual(getattr(second_copy_revision.last_updated_by, User.USERNAME_FIELD), getattr(self.user, User.USERNAME_FIELD)) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
493 |
|
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
494 |
################################################### |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
495 |
# POSTing copy with query arg for REVISION guid |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
496 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
497 |
|
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
498 |
third_copy_data = {"title": "new_title_copy_3"} |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
499 |
third_copy_url = post_url+"?source_revision_id="+source_revision_guid |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
500 |
third_copy_response = self.client.post(third_copy_url, third_copy_data, format="json") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
501 |
third_copy_response_dict = json.loads(third_copy_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
|
502 |
third_copy_response_content_dict = json.loads(third_copy_response_dict.get("content", "{}")) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
503 |
self.assertEqual(third_copy_response.status_code, status.HTTP_201_CREATED) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
504 |
self.assertEqual(Renkan.objects.count(), 4) |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
505 |
# Checking data |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
506 |
# in the response |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
507 |
self.assertNotEqual(third_copy_response_dict.get("id"), source_renkan_guid) |
|
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
508 |
self.assertEqual(third_copy_response_dict.get("source_revision_id"), source_revision_guid) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
509 |
self.assertEqual(third_copy_response_dict.get("title", ""), "new_title_copy_3") |
|
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
|
510 |
for key in list(self.first_test_content_dict.keys()) + list(set(third_copy_response_content_dict.keys()) - set(self.first_test_content_dict.keys())): |
|
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
|
511 |
if key != "updated" and key != "created" and key!= "id" and key != "space_id": |
|
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
|
512 |
self.assertEqual(third_copy_response_content_dict.get(key, ""), self.first_test_content_dict.get(key, "")) |
|
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
|
513 |
self.assertEqual(third_copy_response_dict.get("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
|
514 |
self.assertEqual(third_copy_response_dict.get("last_updated_by", ""), getattr(self.user, User.USERNAME_FIELD)) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
515 |
# in the database |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
516 |
third_copy = Renkan.objects.get(renkan_guid=third_copy_response_dict.get("id", "")) |
|
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
517 |
third_copy_revision = Revision.objects.get(revision_guid=third_copy_response_dict.get("current_revision_id", "")) |
|
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
|
518 |
third_copy_revision_content_dict = json.loads(third_copy_revision.content) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
519 |
self.assertEqual(third_copy.title, "new_title_copy_3") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
520 |
self.assertEqual(third_copy_revision.title, "new_title_copy_3") |
|
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
|
521 |
for key in list(self.first_test_content_dict.keys()) + list(set(third_copy_revision_content_dict.keys()) - set(self.first_test_content_dict.keys())): |
|
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
|
522 |
if key != "updated" and key != "created" and key!= "id" and key != "space_id": |
|
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
|
523 |
self.assertEqual(third_copy_revision_content_dict.get(key, ""), self.first_test_content_dict.get(key, "")) |
|
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
|
524 |
self.assertEqual(getattr(third_copy.creator, User.USERNAME_FIELD), 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
|
525 |
self.assertEqual(getattr(third_copy_revision.creator, User.USERNAME_FIELD), 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
|
526 |
self.assertEqual(getattr(third_copy_revision.last_updated_by, User.USERNAME_FIELD), getattr(self.user, User.USERNAME_FIELD)) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
527 |
|
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
528 |
################################################### |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
529 |
# POSTing copy with source_revision_guid in data |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
530 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
531 |
|
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
532 |
fourth_copy_data = {"source_revision_id": source_revision_guid} |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
533 |
fourth_copy_url = post_url |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
534 |
fourth_copy_response = self.client.post(fourth_copy_url, fourth_copy_data, format="json") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
535 |
fourth_copy_response_dict = json.loads(fourth_copy_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
|
536 |
fourth_copy_response_content_dict = json.loads(fourth_copy_response_dict.get("content", "{}")) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
537 |
self.assertEqual(fourth_copy_response.status_code, status.HTTP_201_CREATED) |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
538 |
self.assertEqual(Renkan.objects.count(), 5) |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
539 |
# Checking data |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
540 |
# in the response |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
541 |
self.assertNotEqual(fourth_copy_response_dict.get("id"), source_renkan_guid) |
|
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
542 |
self.assertEqual(fourth_copy_response_dict.get("source_revision_id"), source_revision_guid) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
543 |
self.assertEqual(fourth_copy_response_dict.get("title", ""), self.first_test_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
|
544 |
for key in list(self.first_test_content_dict.keys()) + list(set(fourth_copy_response_content_dict.keys()) - set(self.first_test_content_dict.keys())): |
|
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
|
545 |
if key != "updated" and key != "created" and key!= "id" and key != "space_id": |
|
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
|
546 |
self.assertEqual(fourth_copy_response_content_dict.get(key, ""), self.first_test_content_dict.get(key, "")) |
|
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
|
547 |
self.assertEqual(fourth_copy_response_dict.get("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
|
548 |
self.assertEqual(fourth_copy_response_dict.get("last_updated_by", ""), getattr(self.user, User.USERNAME_FIELD)) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
549 |
# in the database |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
550 |
fourth_copy = Renkan.objects.get(renkan_guid=fourth_copy_response_dict.get("id", "")) |
|
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
551 |
fourth_copy_revision = Revision.objects.get(revision_guid=fourth_copy_response_dict.get("current_revision_id", "")) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
552 |
self.assertEqual(fourth_copy.title, self.first_test_title) |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
553 |
self.assertEqual(fourth_copy_revision.title, self.first_test_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
|
554 |
fourth_copy_revision_content_dict = json.loads(fourth_copy_revision.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
|
555 |
for key in list(self.first_test_content_dict.keys()) + list(set(fourth_copy_revision_content_dict.keys()) - set(self.first_test_content_dict.keys())): |
|
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
|
556 |
if key != "updated" and key != "created" and key!= "id" and key != "space_id": |
|
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
|
557 |
self.assertEqual(fourth_copy_revision_content_dict.get(key, ""), self.first_test_content_dict.get(key, "")) |
|
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
|
558 |
self.assertEqual(getattr(fourth_copy.creator, User.USERNAME_FIELD), 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
|
559 |
self.assertEqual(getattr(fourth_copy_revision.creator, User.USERNAME_FIELD), 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
|
560 |
self.assertEqual(getattr(fourth_copy_revision.last_updated_by, User.USERNAME_FIELD), getattr(self.user, User.USERNAME_FIELD)) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
561 |
|
|
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
562 |
|
|
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
|
563 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
564 |
# try POSTing copy with bad query arg guid and with bad data 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
|
565 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
566 |
|
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
567 |
bad_copy_data = {"source_revision_id": "bleh_bad_id"} |
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
568 |
bad_copy_data_guid = {"source_revision_id": "00000000-0000-0000-0000-000000000000"} |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
569 |
|
|
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
|
570 |
# with query arg |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
571 |
qarg_bad_copy_url = post_url+"?source_revision_id=bleh_bad_id" |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
572 |
qarg_bad_copy_response = self.client.post(qarg_bad_copy_url, {}, format="json") |
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
573 |
self.assertEqual(qarg_bad_copy_response.status_code, status.HTTP_400_BAD_REQUEST) |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
574 |
# with query arg |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
575 |
qarg_bad_copy_url = post_url+"?source_revision_id=00000000-0000-0000-0000-000000000000" |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
576 |
qarg_bad_copy_response = self.client.post(qarg_bad_copy_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
|
577 |
self.assertEqual(qarg_bad_copy_response.status_code, status.HTTP_404_NOT_FOUND) |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
578 |
# with data |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
579 |
data_bad_copy_url = post_url |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
580 |
data_bad_copy_response = self.client.post(data_bad_copy_url, bad_copy_data, format="json") |
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
581 |
self.assertEqual(data_bad_copy_response.status_code, status.HTTP_400_BAD_REQUEST) |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
582 |
|
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
583 |
data_bad_copy_url = post_url |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
584 |
data_bad_copy_response = self.client.post(data_bad_copy_url, bad_copy_data_guid, 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
|
585 |
self.assertEqual(data_bad_copy_response.status_code, status.HTTP_404_NOT_FOUND) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
586 |
|
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
587 |
|
|
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
|
588 |
def test_delete_renkan(self): |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
589 |
|
|
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
|
590 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
591 |
# 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
|
592 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
593 |
|
| 590 | 594 |
post_url = reverse("v1.0:renkan_list") |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
595 |
data = {"title": self.first_test_title, "content": self.first_test_content} |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
596 |
post_response = self.client.post(post_url, data, format="json") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
597 |
post_response_dict = json.loads(post_response.content.decode()) |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
598 |
to_delete_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
|
599 |
to_delete_revision_guid = post_response_dict.get("current_revision_id", "") |
|
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
|
600 |
to_delete_renkan_ts = json.loads(post_response_dict.get("content", "")).get("updated", "") |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
601 |
|
|
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
|
602 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
603 |
# POSTing copy |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
604 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
605 |
data = {} |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
606 |
post_response = self.client.post(post_url+"?source="+to_delete_renkan_guid, data, format="json") |
|
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
607 |
post_response_dict = json.loads(post_response.content.decode()) |
|
589
0ae11aa255a3
Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents:
588
diff
changeset
|
608 |
copy_renkan_guid = post_response_dict.get("id", "") |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
609 |
|
|
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
|
610 |
# Adding another revision |
|
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
|
611 |
put_data = {"title": self.first_test_title+"_edited!", "validation_timestamp": to_delete_renkan_ts, "create_new_revision": True} |
| 590 | 612 |
put_url = reverse("v1.0:renkan_detail", kwargs={"renkan_guid":to_delete_renkan_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
613 |
put_response = self.client.put(put_url, put_data, 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
|
614 |
self.assertEqual(Renkan.objects.count(), 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
|
615 |
self.assertEqual(Revision.objects.count(), 3) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
616 |
|
|
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
617 |
|
|
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
|
618 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
619 |
# DELETE initial 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
|
620 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
621 |
|
| 590 | 622 |
delete_url = reverse("v1.0:renkan_detail", kwargs={"renkan_guid":to_delete_renkan_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
623 |
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
|
624 |
self.assertEqual(delete_response.status_code, status.HTTP_204_NO_CONTENT) |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
625 |
self.assertEqual(Renkan.objects.count(), 1) # Only the copy remains |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
626 |
self.assertEqual(Revision.objects.count(), 1) # Only the copy initial revision remains |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
627 |
|
|
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
|
628 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
629 |
# Try to GET deleted 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
|
630 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
631 |
|
| 590 | 632 |
get_url = reverse("v1.0:renkan_detail", kwargs={"renkan_guid":to_delete_renkan_guid}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
633 |
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
|
634 |
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
|
635 |
|
|
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
|
636 |
################################################### |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
637 |
# Check that remaining renkan doesn"t have reference to deleted renkan |
|
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
|
638 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
639 |
copy_renkan = Renkan.objects.get(renkan_guid=copy_renkan_guid) |
|
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
|
640 |
self.assertIsNone(copy_renkan.source_revision) |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
641 |
|
|
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
|
642 |
################################################### |
|
fb0041aa74d3
transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff
changeset
|
643 |
# Try to DELETE renkan with wrong 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
|
644 |
################################################### |
|
613
e00a24b711a0
make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents:
610
diff
changeset
|
645 |
|
| 590 | 646 |
delete_url = reverse("v1.0:renkan_detail", kwargs={"renkan_guid": "bad-id"}) |
|
588
95536fa18d0d
Minor adjustements to properly interact with Renkan client
durandn
parents:
587
diff
changeset
|
647 |
delete_response = self.client.delete(delete_url, format="json") |
|
615
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
648 |
self.assertEqual(delete_response.status_code, status.HTTP_400_BAD_REQUEST) |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
649 |
|
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
650 |
################################################### |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
651 |
# Try to DELETE renkan with wrong guid |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
652 |
################################################### |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
653 |
|
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
654 |
delete_url = reverse("v1.0:renkan_detail", kwargs={"renkan_guid": "00000000-0000-0000-0000-000000000000"}) |
|
f3875fbe206a
redo foreign key for renkanmanager, optimize property access, correct unit tests
ymh <ymh.work@gmail.com>
parents:
613
diff
changeset
|
655 |
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
|
656 |
self.assertEqual(delete_response.status_code, status.HTTP_404_NOT_FOUND) |