File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -66,14 +66,19 @@ def test_get_programs(
6666
6767 # Fetch programs after running the fixture so they're in the right order
6868 programs = Program .objects .order_by ("title" ).prefetch_related ("departments" ).all ()
69+ program_ids = programs .values_list ("title" , flat = True ).all ()
6970
7071 num_queries = num_queries_from_programs (programs , "v2" )
7172 with django_assert_max_num_queries (num_queries ) as context :
7273 resp = user_drf_client .get (reverse ("v2:programs_api-list" ))
7374 duplicate_queries_check (context )
7475 programs_data = resp .json ()["results" ]
7576 assert len (programs_data ) == Pagination .page_size
76- for program , program_data in zip (programs , programs_data ):
77+ # Assert that things are in the correct order by checking the IDs
78+ assert [result ["title" ] for result in programs_data ] == list (program_ids )
79+
80+ for program_data in programs_data :
81+ program = programs .get (pk = program_data ["id" ])
7782 # Clear cached property to ensure consistent data between API and serializer
7883 if hasattr (program , "_courses_with_requirements_data" ):
7984 delattr (program , "_courses_with_requirements_data" )
You can’t perform that action at this time.
0 commit comments