server/python/django2/renkanmanager/tests/v1_0/tests_renkan.py
author ymh <ymh.work@gmail.com>
Mon, 13 Jun 2016 14:23:58 +0200
changeset 613 e00a24b711a0
parent 610 b9edc1c1538a
child 615 f3875fbe206a
permissions -rw-r--r--
make renkanmanager test run locally
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
    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
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
    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
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   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", ""))
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
   145
        self.assertEqual(self.test_workspace_guid, 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
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   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
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   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")
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
   179
        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
   180
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
   181
        ###################################################
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
   182
        # 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
   183
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   184
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
   185
        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
   186
        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
   187
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
   188
        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
   189
        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
   190
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
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
    def test_get_renkan(self):
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   193
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
   194
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   195
        # 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
   196
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   197
590
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   198
        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
   199
        data = {}
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   200
        post_response = self.client.post(post_url, data, format="json")
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   201
        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
   202
        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
   203
        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
   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
        # 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
   207
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   208
590
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   209
        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
   210
        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
   211
        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
   212
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
   213
        # Checking GET data
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   214
        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
   215
        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
   216
        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
   217
        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
   218
        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
   219
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
   220
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   221
        # 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
   222
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   223
590
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   224
        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
   225
        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
   226
        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
   227
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
   228
    def test_get_renkan_list(self):
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   229
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
   230
        ###################################################
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
        # 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
   232
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   233
590
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   234
        post_url = reverse("v1.0:renkan_list")
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   235
        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
   236
        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
   237
        self.client.post(post_url, first_data, format="json")
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   238
        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
   239
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
   240
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   241
        # 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
   242
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   243
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
   244
        get_url = post_url
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   245
        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
   246
        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
   247
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   248
        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
   249
        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
   250
        self.assertEqual(len(get_response_content), 2)
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   251
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
   252
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   253
        # 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
   254
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   255
590
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   256
        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
   257
        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
   258
        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
   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), 1)
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   271
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   272
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   273
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   274
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   275
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
   276
    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
   277
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   278
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   279
        # 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
   280
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   281
590
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   282
        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
   283
        data = {}
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   284
        post_response = self.client.post(post_url, data, format="json")
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   285
        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
   286
        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
   287
        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
   288
        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
   289
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
   290
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   291
        # 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
   292
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   293
590
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   294
        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
   295
        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
   296
        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
   297
        put_data = {
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   298
            "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
   299
            "content" : json.dumps(put_content_dict),
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   300
            "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
   301
        }
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   302
        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
   303
        self.assertEqual(put_response.status_code, status.HTTP_200_OK)
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   304
        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
   305
        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
   306
        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
   307
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   308
        # 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
   309
        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
   310
        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
   311
        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
   312
        self.assertEqual(updated_project.revision_count, 1)
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   313
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
   314
        self.assertEqual(revision_guid, 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
   315
        # 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
   316
        #     in the reponse
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   317
        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
   318
        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
   319
            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
   320
                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
   321
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
   322
        #     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
   323
        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
   324
        updated_revision_content_dict = json.loads(updated_revision.content)
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   325
        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
   326
        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
   327
            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
   328
                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
   329
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
   330
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   331
        # 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
   332
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   333
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
   334
        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
   335
        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
   336
        put_data = {
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   337
            "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
   338
            "content" : json.dumps(put_content_dict),
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   339
            "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
   340
        }
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   341
        put_response = self.client.put(put_url, put_data, format="json")
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
   342
        self.assertEqual(put_response.status_code, status.HTTP_200_OK)
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   343
        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
   344
        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
   345
        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
   346
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
   347
        # 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
   348
        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
   349
        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
   350
        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
   351
        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
   352
        self.assertEqual(Revision.objects.count(), 2)
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   353
        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
   354
        self.assertEqual(updated_project.revision_count, 2)
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   355
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
        # checking project now points towards new 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
   357
        self.assertEqual(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
   358
        # 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
   359
        #     in the reponse
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   360
        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
   361
        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
   362
            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
   363
                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
   364
        #     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
   365
        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
   366
        updated_revision_content_dict = json.loads(updated_revision.content)
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   367
        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
   368
        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
   369
            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
   370
                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
   371
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
   372
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   373
        # 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
   374
        ###################################################
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
        put_data = {
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   377
            "title" : self.third_test_title,
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   378
            "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
   379
            "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
   380
        }
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   381
        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
   382
        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
   383
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
        ###################################################
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
        # 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
   386
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   387
590
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   388
        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
   389
        put_response = self.client.put(put_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
   390
        self.assertEqual(put_response.status_code, status.HTTP_404_NOT_FOUND)
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   391
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   392
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
   393
    def test_copy_renkan(self):
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   394
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
   395
        ###################################################
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
        # 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
   397
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   398
590
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   399
        post_url = reverse("v1.0:renkan_list")
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   400
        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
   401
        post_response = self.client.post(post_url, data, format="json")
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   402
        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
   403
        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
   404
        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
   405
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
   406
        ###################################################
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   407
        # 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
   408
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   409
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   410
        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
   411
        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
   412
        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
   413
        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
   414
        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
   415
        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
   416
        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
   417
        # 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
   418
        #     in the response
589
0ae11aa255a3 Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents: 588
diff changeset
   419
        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
   420
        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
   421
        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
   422
        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
   423
            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
   424
                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
   425
        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
   426
        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
   427
        #     in the database
589
0ae11aa255a3 Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents: 588
diff changeset
   428
        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
   429
        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
   430
        self.assertEqual(first_copy.title, "new_title_copy_1")
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   431
        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
   432
        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
   433
        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
   434
            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
   435
                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
   436
        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
   437
        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
   438
        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
   439
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
   440
        ###################################################
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   441
        # 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
   442
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   443
589
0ae11aa255a3 Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents: 588
diff changeset
   444
        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
   445
        second_copy_url = post_url
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   446
        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
   447
        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
   448
        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
   449
        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
   450
        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
   451
        # 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
   452
        #     in the response
589
0ae11aa255a3 Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents: 588
diff changeset
   453
        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
   454
        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
   455
        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
   456
        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
   457
            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
   458
                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
   459
        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
   460
        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
   461
        #     in the database
589
0ae11aa255a3 Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents: 588
diff changeset
   462
        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
   463
        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
   464
        self.assertEqual(second_copy.title, "new_title_copy_2")
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   465
        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
   466
        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
   467
        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
   468
            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
   469
                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
   470
        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
   471
        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
   472
        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
   473
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   474
        ###################################################
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   475
        # POSTing copy with query arg for REVISION guid
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   476
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   477
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   478
        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
   479
        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
   480
        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
   481
        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
   482
        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
   483
        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
   484
        self.assertEqual(Renkan.objects.count(), 4)
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   485
        # Checking data
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   486
        #     in the response
589
0ae11aa255a3 Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents: 588
diff changeset
   487
        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
   488
        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
   489
        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
   490
        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
   491
            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
   492
                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
   493
        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
   494
        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
   495
        #     in the database
589
0ae11aa255a3 Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents: 588
diff changeset
   496
        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
   497
        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
   498
        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
   499
        self.assertEqual(third_copy.title, "new_title_copy_3")
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   500
        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
   501
        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
   502
            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
   503
                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
   504
        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
   505
        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
   506
        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
   507
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   508
        ###################################################
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   509
        # POSTing copy with source_revision_guid in data
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   510
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   511
589
0ae11aa255a3 Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents: 588
diff changeset
   512
        fourth_copy_data = {"source_revision_id": source_revision_guid}
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   513
        fourth_copy_url = post_url
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   514
        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
   515
        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
   516
        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
   517
        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
   518
        self.assertEqual(Renkan.objects.count(), 5)
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   519
        # Checking data
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   520
        #     in the response
589
0ae11aa255a3 Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents: 588
diff changeset
   521
        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
   522
        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
   523
        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
   524
        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
   525
            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
   526
                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
   527
        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
   528
        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
   529
        #     in the database
589
0ae11aa255a3 Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents: 588
diff changeset
   530
        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
   531
        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
   532
        self.assertEqual(fourth_copy.title, self.first_test_title)
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   533
        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
   534
        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
   535
        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
   536
            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
   537
                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
   538
        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
   539
        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
   540
        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
   541
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   542
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
   543
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   544
        # 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
   545
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   546
589
0ae11aa255a3 Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents: 588
diff changeset
   547
        bad_copy_data = {"source_revision_id": "bleh_bad_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
   548
        #    with query arg
589
0ae11aa255a3 Moved python2/django into a django2 folder for consistency + clarified serializers fields name
durandn
parents: 588
diff changeset
   549
        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
   550
        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
   551
        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
   552
        #    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
   553
        data_bad_copy_url = post_url
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   554
        data_bad_copy_response = self.client.post(data_bad_copy_url, bad_copy_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
   555
        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
   556
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
   557
    def test_delete_renkan(self):
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   558
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
   559
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   560
        # 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
   561
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   562
590
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   563
        post_url = reverse("v1.0:renkan_list")
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   564
        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
   565
        post_response = self.client.post(post_url, data, format="json")
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   566
        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
   567
        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
   568
        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
   569
        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
   570
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
   571
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   572
        # 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
   573
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   574
        data = {}
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   575
        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
   576
        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
   577
        copy_renkan_guid = post_response_dict.get("id", "")
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   578
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
   579
        # 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
   580
        put_data = {"title": self.first_test_title+"_edited!", "validation_timestamp": to_delete_renkan_ts, "create_new_revision": True}
590
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   581
        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
   582
        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
   583
        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
   584
        self.assertEqual(Revision.objects.count(), 3)
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   585
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   586
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
   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
        # 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
   589
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   590
590
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   591
        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
   592
        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
   593
        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
   594
        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
   595
        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
   596
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
   597
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   598
        # 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
   599
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   600
590
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   601
        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
   602
        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
   603
        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
   604
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
   605
        ###################################################
588
95536fa18d0d Minor adjustements to properly interact with Renkan client
durandn
parents: 587
diff changeset
   606
        # 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
   607
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   608
        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
   609
        self.assertIsNone(copy_renkan.source_revision)
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   610
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
   611
        ###################################################
fb0041aa74d3 transfer work on renkanmanager into a renkan/server/python2 folder: reworked models, implemented simple API basic permissions, wrote tests
durandn
parents:
diff changeset
   612
        # 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
   613
        ###################################################
613
e00a24b711a0 make renkanmanager test run locally
ymh <ymh.work@gmail.com>
parents: 610
diff changeset
   614
590
3be2a86981c2 API versioning via namespace
durandn
parents: 589
diff changeset
   615
        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
   616
        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
   617
        self.assertEqual(delete_response.status_code, status.HTTP_404_NOT_FOUND)