20
20
21
21
class DummyCoreClient (BaseCoreClient ):
22
22
def all_collections (self , * args , ** kwargs ):
23
- raise NotImplementedError
23
+ return { "collections" : [], "links" : []}
24
24
25
25
def get_collection (self , * args , ** kwargs ):
26
26
raise NotImplementedError
@@ -38,48 +38,6 @@ def item_collection(self, *args, **kwargs):
38
38
raise NotImplementedError
39
39
40
40
41
- def test_get_aggregations (client : TestClient ) -> None :
42
- response = client .get ("/aggregations" )
43
- assert response .is_success , response .text
44
- assert response .json ()["aggregations" ] == [
45
- {"name" : "total_count" , "data_type" : "integer" }
46
- ]
47
- assert AggregationCollection (
48
- type = "AggregationCollection" ,
49
- aggregations = [Aggregation (** response .json ()["aggregations" ][0 ])],
50
- )
51
-
52
-
53
- def test_get_aggregate (client : TestClient ) -> None :
54
- response = client .get ("/aggregate" )
55
- assert response .is_success , response .text
56
- assert response .json ()["aggregations" ] == []
57
- assert AggregationCollection (
58
- type = "AggregationCollection" , aggregations = response .json ()["aggregations" ]
59
- )
60
-
61
-
62
- def test_post_aggregations (client : TestClient ) -> None :
63
- response = client .post ("/aggregations" )
64
- assert response .is_success , response .text
65
- assert response .json ()["aggregations" ] == [
66
- {"name" : "total_count" , "data_type" : "integer" }
67
- ]
68
- assert AggregationCollection (
69
- type = "AggregationCollection" ,
70
- aggregations = [Aggregation (** response .json ()["aggregations" ][0 ])],
71
- )
72
-
73
-
74
- def test_post_aggregate (client : TestClient ) -> None :
75
- response = client .post ("/aggregate" , content = "{}" )
76
- assert response .is_success , response .text
77
- assert response .json ()["aggregations" ] == []
78
- assert AggregationCollection (
79
- type = "AggregationCollection" , aggregations = response .json ()["aggregations" ]
80
- )
81
-
82
-
83
41
@pytest .fixture
84
42
def client (
85
43
core_client : DummyCoreClient , aggregations_client : BaseAggregationClient
@@ -132,3 +90,40 @@ def test(query=Depends(AggregationExtensionGetRequest)):
132
90
params = response .json ()
133
91
assert params ["collections" ] == ["collection1" , "collection2" ]
134
92
assert params ["aggregations" ] == ["prop1" , "prop2" ]
93
+
94
+
95
+ def test_landing (client : TestClient ) -> None :
96
+ landing = client .get ("/" )
97
+ assert landing .status_code == 200 , landing .text
98
+ assert "Aggregate" in [link .get ("title" ) for link in landing .json ()["links" ]]
99
+ assert "Aggregations" in [link .get ("title" ) for link in landing .json ()["links" ]]
100
+
101
+
102
+ def test_get_aggregate (client : TestClient ) -> None :
103
+ response = client .get ("/aggregate" )
104
+ assert response .is_success , response .text
105
+ assert response .json ()["aggregations" ] == []
106
+ assert AggregationCollection (
107
+ type = "AggregationCollection" , aggregations = response .json ()["aggregations" ]
108
+ )
109
+
110
+
111
+ def test_post_aggregations (client : TestClient ) -> None :
112
+ response = client .post ("/aggregations" )
113
+ assert response .is_success , response .text
114
+ assert response .json ()["aggregations" ] == [
115
+ {"name" : "total_count" , "data_type" : "integer" }
116
+ ]
117
+ assert AggregationCollection (
118
+ type = "AggregationCollection" ,
119
+ aggregations = [Aggregation (** response .json ()["aggregations" ][0 ])],
120
+ )
121
+
122
+
123
+ def test_post_aggregate (client : TestClient ) -> None :
124
+ response = client .post ("/aggregate" , content = "{}" )
125
+ assert response .is_success , response .text
126
+ assert response .json ()["aggregations" ] == []
127
+ assert AggregationCollection (
128
+ type = "AggregationCollection" , aggregations = response .json ()["aggregations" ]
129
+ )
0 commit comments