11"""Test /collections endpoints."""
22
3+ collection_number = 14
4+
35
46def test_collections (app ):
57 """Test /collections endpoint."""
@@ -8,8 +10,8 @@ def test_collections(app):
810 assert response .headers ["content-type" ] == "application/json"
911 body = response .json ()
1012 assert ["links" , "numberMatched" , "numberReturned" , "collections" ] == list (body )
11- assert body ["numberMatched" ] == 13
12- assert body ["numberReturned" ] == 13
13+ assert body ["numberMatched" ] == collection_number
14+ assert body ["numberReturned" ] == collection_number
1315
1416 ids = [x ["id" ] for x in body ["collections" ]]
1517 assert "public.landsat_wrs" in ids
@@ -27,56 +29,70 @@ def test_collections_search(app):
2729 """Test /collections endpoint."""
2830 response = app .get ("/collections" , params = {"limit" : 1 })
2931 body = response .json ()
30- assert body ["numberMatched" ] == 13
32+ assert body ["numberMatched" ] == collection_number
3133 assert body ["numberReturned" ] == 1
3234 rels = [x ["rel" ] for x in body ["links" ]]
3335 assert "next" in rels
3436 assert "prev" not in rels
3537
3638 response = app .get ("/collections" , params = {"limit" : 1 , "offset" : 1 })
3739 body = response .json ()
38- assert body ["numberMatched" ] == 13
40+ assert body ["numberMatched" ] == collection_number
3941 assert body ["numberReturned" ] == 1
4042 rels = [x ["rel" ] for x in body ["links" ]]
4143 assert "next" in rels
4244 assert "prev" in rels
4345
44- response = app .get ("/collections" , params = {"limit" : 1 , "offset" : 12 })
46+ response = app .get (
47+ "/collections" , params = {"limit" : 1 , "offset" : collection_number - 1 }
48+ )
4549 body = response .json ()
46- assert body ["numberMatched" ] == 13
50+ assert body ["numberMatched" ] == collection_number
4751 assert body ["numberReturned" ] == 1
4852 rels = [x ["rel" ] for x in body ["links" ]]
4953 assert "next" not in rels
5054 assert "prev" in rels
5155
5256 response = app .get ("/collections" , params = {"bbox" : "-180,81,180,87" })
5357 body = response .json ()
54- assert body ["numberMatched" ] == 10
58+ assert (
59+ body ["numberMatched" ] == collection_number - 3
60+ ) # 2 collections are not within the bbox
5561 ids = [x ["id" ] for x in body ["collections" ]]
5662 assert "public.nongeo_data" not in ids
5763 assert "public.canada" not in ids
5864
5965 response = app .get ("/collections" , params = {"datetime" : "../2022-12-31T23:59:59Z" })
6066 body = response .json ()
61- assert body ["numberMatched" ] == 3
67+ assert body ["numberMatched" ] == 4
6268 ids = [x ["id" ] for x in body ["collections" ]]
63- assert ["public.my_data" , "public.my_data_alt" , "public.nongeo_data" ] == ids
69+ assert [
70+ "public.my_data" ,
71+ "public.my_data_alt" ,
72+ "public.my_data_geo" ,
73+ "public.nongeo_data" ,
74+ ] == ids
6475
6576 response = app .get ("/collections" , params = {"datetime" : "2022-12-31T23:59:59Z/.." })
6677 body = response .json ()
6778 assert body ["numberMatched" ] == 0
6879
6980 response = app .get ("/collections" , params = {"datetime" : "2003-12-31T23:59:59Z/.." })
7081 body = response .json ()
71- assert body ["numberMatched" ] == 3
82+ assert body ["numberMatched" ] == 4
7283 ids = [x ["id" ] for x in body ["collections" ]]
73- assert ["public.my_data" , "public.my_data_alt" , "public.nongeo_data" ] == ids
84+ assert [
85+ "public.my_data" ,
86+ "public.my_data_alt" ,
87+ "public.my_data_geo" ,
88+ "public.nongeo_data" ,
89+ ] == ids
7490
7591 response = app .get ("/collections" , params = {"datetime" : "2004-12-31T23:59:59Z/.." })
7692 body = response .json ()
77- assert body ["numberMatched" ] == 2
93+ assert body ["numberMatched" ] == 3
7894 ids = [x ["id" ] for x in body ["collections" ]]
79- assert ["public.my_data" , "public.my_data_alt" ] == ids
95+ assert ["public.my_data" , "public.my_data_alt" , "public.my_data_geo" ] == ids
8096
8197 response = app .get (
8298 "/collections" , params = {"datetime" : "2004-01-01T00:00:00Z/2004-12-31T23:59:59Z" }
0 commit comments