File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
example/tests/integration Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 1- import pytest , json
1+ import pytest
22from django .core .urlresolvers import reverse
3+
34from example .tests .utils import load_json
45
56pytestmark = pytest .mark .django_db
67
78
89def test_included_data_on_list (multiple_entries , client ):
9- multiple_entries [1 ].comments = []
1010 response = client .get (reverse ("entry-list" ) + '?include=comments' )
1111 included = load_json (response .content ).get ('included' )
1212
13+ assert len (load_json (response .content )['data' ]) == len (multiple_entries )
1314 assert [x .get ('type' ) for x in included ] == ['comments' ]
15+ assert (len ([resource for resource in included if resource ["type" ] == "comments" ]) ==
16+ sum ([entry .comment_set .count () for entry in multiple_entries ]))
17+
1418
1519def test_included_data_on_detail (single_entry , client ):
1620 response = client .get (reverse ("entry-detail" , kwargs = {'pk' : single_entry .pk }) + '?include=comments' )
1721 included = load_json (response .content ).get ('included' )
1822
1923 assert [x .get ('type' ) for x in included ] == ['comments' ]
20-
24+ assert (len ([resource for resource in included if resource ["type" ] == "comments" ]) ==
25+ single_entry .comment_set .count ())
You can’t perform that action at this time.
0 commit comments