diff --git a/rest/tests/test_vocabulary.py b/rest/tests/test_vocabulary.py index 074a96b2..714a6500 100644 --- a/rest/tests/test_vocabulary.py +++ b/rest/tests/test_vocabulary.py @@ -421,17 +421,18 @@ def test_vocabulary_pagination(self): # should still be the only thing there. self.assertEqual(vocabs.count(), 1) expected = [ - Vocabulary.objects.create( + VocabularySerializer(Vocabulary.objects.create( repository=self.repo, name="name{i}".format(i=i), description="description", required=True, vocabulary_type=Vocabulary.FREE_TAGGING, weight=1000, - ) for i in range(40)] + )).data for i in range(40)] # The curator status vocabulary will be first by ID. - expected.append(vocabs[0]) + expected.append(VocabularySerializer(vocabs[0]).data) + expected.sort(key=lambda x: x["id"]) resp = self.client.get( '{repo_base}{repo_slug}/vocabularies/'.format( @@ -442,15 +443,14 @@ def test_vocabulary_pagination(self): vocabularies = as_json(resp) self.assertEqual(41, vocabularies['count']) - # Sort both lists in preparation for comparison. - expected_dicts = [VocabularySerializer(x).data for x in expected] - expected_dicts.sort(key=lambda x: x["id"]) + # Sort both lists in preparation for comparisons. + expected.sort(key=lambda x: x["id"]) from_api = sorted(vocabularies['results'], key=lambda x: x["id"]) expected_count = 20 self.assertEqual(expected_count, len(from_api)) self.assertEqual( - expected_dicts[:expected_count], + expected[:expected_count], from_api, ) @@ -466,7 +466,7 @@ def test_vocabulary_pagination(self): self.assertEqual(41, vocabularies['count']) self.assertEqual( from_api, - expected_dicts[expected_count:expected_count*2], + expected[expected_count:expected_count*2], ) def test_term_pagination(self):