10
10
11
11
class TestContext (TestCase ):
12
12
def setUp (self ):
13
- self .test_service = 'http://esgf-index1.ceda.ac.uk /esg-search'
13
+ self .test_service = 'http://esgf-data.dkrz.de /esg-search'
14
14
self .cache = os .path .join (os .path .dirname (__file__ ), 'url_cache' )
15
15
16
16
def test_context_freetext (self ):
@@ -35,8 +35,7 @@ def test_context_facets_multivalue(self):
35
35
self .assertTrue (context2 .hit_count > 0 )
36
36
37
37
self .assertTrue (context2 .facet_constraints ['project' ] == 'CMIP5' )
38
- self .assertTrue (sorted (context2 .facet_constraints .getall ('model' ))
39
- == ['IPSL-CM5A-LR' , 'IPSL-CM5A-MR' ])
38
+ self .assertTrue (sorted (context2 .facet_constraints .getall ('model' )) == ['IPSL-CM5A-LR' , 'IPSL-CM5A-MR' ])
40
39
41
40
def test_context_facet_multivalue2 (self ):
42
41
conn = SearchConnection (self .test_service , cache = self .cache )
@@ -45,8 +44,7 @@ def test_context_facet_multivalue2(self):
45
44
context .facet_constraints .getall ('model' ) == ['IPSL-CM5A-MR' ])
46
45
47
46
context2 = context .constrain (model = ['IPSL-CM5A-MR' , 'IPSL-CM5A-LR' ])
48
- self .assertTrue (sorted (context2 .facet_constraints .getall ('model' ))
49
- == ['IPSL-CM5A-LR' , 'IPSL-CM5A-MR' ])
47
+ self .assertTrue (sorted (context2 .facet_constraints .getall ('model' )) == ['IPSL-CM5A-LR' , 'IPSL-CM5A-MR' ])
50
48
51
49
def test_context_facet_multivalue3 (self ):
52
50
conn = SearchConnection (self .test_service , cache = self .cache )
@@ -94,18 +92,29 @@ def test_facet_count(self):
94
92
self .assertTrue (list (counts ['project' ].keys ()) == ['CMIP5' ])
95
93
96
94
def test_distrib (self ):
97
- conn = SearchConnection (self .test_service , cache = self .cache ,
98
- distrib = False )
95
+ conn = SearchConnection (self .test_service , distrib = False )
99
96
100
97
context = conn .new_context (project = 'CMIP5' )
101
98
count1 = context .hit_count
102
99
103
- conn2 = SearchConnection (self .test_service , cache = self .cache ,
104
- distrib = True )
100
+ conn2 = SearchConnection (self .test_service , distrib = True )
105
101
context = conn2 .new_context (project = 'CMIP5' )
106
102
count2 = context .hit_count
107
103
108
- self .assertTrue (count1 < count2 )
104
+ assert count1 < count2
105
+
106
+ # @pytest.mark.skip(reason="cache fails on python 3.7")
107
+ def test_distrib_with_cache (self ):
108
+ conn = SearchConnection (self .test_service , cache = self .cache , distrib = False )
109
+
110
+ context = conn .new_context (project = 'CMIP5' )
111
+ count1 = context .hit_count
112
+
113
+ conn2 = SearchConnection (self .test_service , cache = self .cache , distrib = True )
114
+ context = conn2 .new_context (project = 'CMIP5' )
115
+ count2 = context .hit_count
116
+
117
+ assert count1 < count2
109
118
110
119
def test_constrain (self ):
111
120
conn = SearchConnection (self .test_service , cache = self .cache )
@@ -149,24 +158,24 @@ def test_negative_facet(self):
149
158
context3 = context .constrain (experiment = not_equals ('historical' ))
150
159
hits3 = context3 .hit_count
151
160
152
- self . assertTrue ( hits1 == hits2 + hits3 )
161
+ assert hits1 == hits2 + hits3
153
162
154
163
def test_replica (self ):
155
164
# Test that we can exclude replicas
156
165
# This tests assumes the test dataset is replicated
157
- conn = SearchConnection (self .test_service , cache = self . cache )
166
+ conn = SearchConnection (self .test_service )
158
167
qry = 'id:cmip5.output1.MOHC.HadGEM2-ES.rcp45.mon.atmos.Amon.r1i1p1.*'
159
168
version = '20111128'
160
169
161
170
# Search for all replicas
162
171
context = conn .new_context (query = qry , version = version )
163
- self . assertTrue ( context . hit_count > 2 ,
164
- 'Expecting more than 2 search hits for replicas' )
172
+ # Expecting more than 2 search hits for replicas
173
+ assert context . hit_count > 2
165
174
166
175
# Search for only one replicant
167
176
context = conn .new_context (query = qry , replica = False , version = version )
168
- self . assertTrue ( context . hit_count == 1 ,
169
- 'Expecting one search replica' )
177
+ # Expecting one search replica
178
+ assert context . hit_count == 1
170
179
171
180
def test_response_from_bad_parameter (self ):
172
181
# Test that a bad parameter name raises a useful exception
@@ -186,21 +195,18 @@ def test_response_from_bad_parameter(self):
186
195
"No JSON object could be decoded" ))
187
196
188
197
def test_context_project_cmip6 (self ):
189
- test_service = 'https://esgf-node.ipsl.upmc.fr /esg-search'
198
+ test_service = 'https://esgf-node.llnl.gov /esg-search'
190
199
conn = SearchConnection (test_service )
191
200
192
- context = conn .new_context (project = 'CMIP6' )
193
- self .assertEqual (context .hit_count , 1973 )
194
-
195
- context2 = context .constrain (realm = "atmosChem" )
196
- self .assertEqual (context2 .hit_count , 10 )
201
+ context = conn .new_context (project = 'CMIP6' , institution_id = 'AWI' , distrib = False )
202
+ self .assertTrue (context .hit_count > 100 )
197
203
204
+ context2 = context .constrain (variable = 'tas' )
205
+ self .assertTrue (context2 .hit_count > 10 )
198
206
199
207
def test_context_project_c3s_cmip5 (self ):
200
208
test_service = 'https://cp4cds-index1.ceda.ac.uk/esg-search'
201
209
conn = SearchConnection (test_service )
202
210
203
211
context = conn .new_context (project = 'c3s-cmip5' )
204
212
self .assertTrue (context .hit_count > 20000 )
205
-
206
-
0 commit comments