1
1
"""Test /collections endpoints."""
2
2
3
+ collection_number = 14
4
+
3
5
4
6
def test_collections (app ):
5
7
"""Test /collections endpoint."""
@@ -8,8 +10,8 @@ def test_collections(app):
8
10
assert response .headers ["content-type" ] == "application/json"
9
11
body = response .json ()
10
12
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
13
15
14
16
ids = [x ["id" ] for x in body ["collections" ]]
15
17
assert "public.landsat_wrs" in ids
@@ -27,56 +29,70 @@ def test_collections_search(app):
27
29
"""Test /collections endpoint."""
28
30
response = app .get ("/collections" , params = {"limit" : 1 })
29
31
body = response .json ()
30
- assert body ["numberMatched" ] == 13
32
+ assert body ["numberMatched" ] == collection_number
31
33
assert body ["numberReturned" ] == 1
32
34
rels = [x ["rel" ] for x in body ["links" ]]
33
35
assert "next" in rels
34
36
assert "prev" not in rels
35
37
36
38
response = app .get ("/collections" , params = {"limit" : 1 , "offset" : 1 })
37
39
body = response .json ()
38
- assert body ["numberMatched" ] == 13
40
+ assert body ["numberMatched" ] == collection_number
39
41
assert body ["numberReturned" ] == 1
40
42
rels = [x ["rel" ] for x in body ["links" ]]
41
43
assert "next" in rels
42
44
assert "prev" in rels
43
45
44
- response = app .get ("/collections" , params = {"limit" : 1 , "offset" : 12 })
46
+ response = app .get (
47
+ "/collections" , params = {"limit" : 1 , "offset" : collection_number - 1 }
48
+ )
45
49
body = response .json ()
46
- assert body ["numberMatched" ] == 13
50
+ assert body ["numberMatched" ] == collection_number
47
51
assert body ["numberReturned" ] == 1
48
52
rels = [x ["rel" ] for x in body ["links" ]]
49
53
assert "next" not in rels
50
54
assert "prev" in rels
51
55
52
56
response = app .get ("/collections" , params = {"bbox" : "-180,81,180,87" })
53
57
body = response .json ()
54
- assert body ["numberMatched" ] == 10
58
+ assert (
59
+ body ["numberMatched" ] == collection_number - 3
60
+ ) # 2 collections are not within the bbox
55
61
ids = [x ["id" ] for x in body ["collections" ]]
56
62
assert "public.nongeo_data" not in ids
57
63
assert "public.canada" not in ids
58
64
59
65
response = app .get ("/collections" , params = {"datetime" : "../2022-12-31T23:59:59Z" })
60
66
body = response .json ()
61
- assert body ["numberMatched" ] == 3
67
+ assert body ["numberMatched" ] == 4
62
68
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
64
75
65
76
response = app .get ("/collections" , params = {"datetime" : "2022-12-31T23:59:59Z/.." })
66
77
body = response .json ()
67
78
assert body ["numberMatched" ] == 0
68
79
69
80
response = app .get ("/collections" , params = {"datetime" : "2003-12-31T23:59:59Z/.." })
70
81
body = response .json ()
71
- assert body ["numberMatched" ] == 3
82
+ assert body ["numberMatched" ] == 4
72
83
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
74
90
75
91
response = app .get ("/collections" , params = {"datetime" : "2004-12-31T23:59:59Z/.." })
76
92
body = response .json ()
77
- assert body ["numberMatched" ] == 2
93
+ assert body ["numberMatched" ] == 3
78
94
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
80
96
81
97
response = app .get (
82
98
"/collections" , params = {"datetime" : "2004-01-01T00:00:00Z/2004-12-31T23:59:59Z" }
0 commit comments