Tomek Wójcik
c75ea4ea9d
* `bthlabs-jsonrpc-aiohttp` v1.0.0 * `bthlabs-jsonrpc-core` v1.0.0 * `bthlabs-jsonrpc-django` v1.0.0
33 lines
907 B
Python
33 lines
907 B
Python
# -*- coding: utf-8 -*-
|
|
import pytest
|
|
|
|
from bthlabs_jsonrpc_django import serializer
|
|
from testing.factories import ThingFactory
|
|
from testing.models import Thing
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_serialize_value_query_set():
|
|
# Given
|
|
things = [ThingFactory() for _ in range(0, 3)]
|
|
|
|
query_set = Thing.objects.\
|
|
filter(pk__in=[thing.pk for thing in things]).\
|
|
order_by('pk')
|
|
|
|
the_serializer = serializer.DjangoJSONRPCSerializer('spam')
|
|
|
|
# When
|
|
result = the_serializer.serialize_value(query_set)
|
|
|
|
# Then
|
|
assert isinstance(result, list)
|
|
assert len(result) == 3
|
|
|
|
expected_serialized_thing = things[0].to_rpc()
|
|
expected_serialized_thing.update({
|
|
'created_at': expected_serialized_thing['created_at'].isoformat(),
|
|
'modified_at': expected_serialized_thing['modified_at'].isoformat(),
|
|
})
|
|
assert result[0] == expected_serialized_thing
|