예제 #1
0
    def test_decode(self):
        data = '{"items": [{"lastname": "1", "id": 1, "firstname": "User"}, {"lastname": "2", "id": 2, "firstname": "User"}], "total": 2}'

        expected_result = {
            'total': 2,
            'items': [
                {
                    "id": 1,
                    "firstname": "User",
                    "lastname": "1"
                },
                {
                    "id": 2,
                    "firstname": "User",
                    "lastname": "2"
                },
            ]
        }

        result = serializer.decode(data)

        self.assertEqual(result, expected_result)
예제 #2
0
    def test_decode(self):
        data = '{"items": [{"lastname": "1", "id": 1, "firstname": "User"}, {"lastname": "2", "id": 2, "firstname": "User"}], "total": 2}'

        expected_result = {
            'total':
            2,
            'items': [
                {
                    "id": 1,
                    "firstname": "User",
                    "lastname": "1"
                },
                {
                    "id": 2,
                    "firstname": "User",
                    "lastname": "2"
                },
            ]
        }

        result = serializer.decode(data)

        self.assertEqual(result, expected_result)
예제 #3
0
 def _serialize_decode(self, data):
     return serializer.decode(data)
예제 #4
0
 def _serialize_decode(self, data):
     return serializer.decode(data)
예제 #5
0
    def assertResponse(self, response, status_code, result):
        decoded_response = serializer.decode(response.data)

        self.assertEquals(response.status_code, status_code)
        self.assertEquals(decoded_response, result)