@@ -83,83 +83,81 @@ def teardown_method(self):
83
83
shutil .rmtree (self .out_dir_b , ignore_errors = True )
84
84
Cache .clear ()
85
85
86
- # do_not_run
87
- # The slow test does not run but Carlo has fixed it
88
- # @pytest.mark.slow
89
- # class TestCachingSlow(ETRS89TestCase):
90
- # case_dir = os.path.join(os.path.dirname(__file__), 'data', 'LF_ETRS89_UseCase')
91
- #
92
- # modules_to_set = (
93
- # 'SplitRouting',
94
- # 'simulateReservoirs',
95
- # 'simulateLakes',
96
- # 'drainedIrrigation',
97
- # 'openwaterevapo',
98
- # 'riceIrrigation',
99
- # 'wateruse',
100
- # 'useWaterDemandAveYear',
101
- # 'wateruseRegion',
102
- # 'TransientWaterDemandChange',
103
- # )
104
- # settings_files = {
105
- # 'base': os.path.join(case_dir, 'settings/base.xml'),
106
- # 'prerun': os.path.join(case_dir, 'settings/prerun.xml')
107
- # }
108
- #
109
- # def run(self, dt_sec, step_start, step_end):
110
- # output_dir = mk_path_out('data/LF_ETRS89_UseCase/out/test_results{}'.format(dt_sec))
111
- # opts_to_unset = (
112
- # "repStateSites", "repRateSites", "repStateUpsGauges", "repRateUpsGauges", "repMeteoUpsGauges",
113
- # "repsimulateLakes", "repStateMaps",
114
- # "repsimulateReservoirs", "repSnowMaps", "repPFMaps", "repLZMaps", "repUZMaps",
115
- # "repGwPercUZLZMaps", "repRWS", "repTotalWUse", "repWIndex",
116
- # "repSurfaceRunoffMaps", "repRainMaps", "repSnowMaps", "repSnowCoverMaps", "repSnowMeltMaps", "repThetaMaps",
117
- # "repThetaForestMaps", "repLZMaps", "repUZMaps",
118
- # "repGwPercUZLZMaps", "repRWS", "repPFMaps", "repPFForestMaps"
119
- # )
120
- # settings = setoptions(self.settings_files['base'],
121
- # opts_to_set=('repDischargeTs', 'repDischargeMaps',) + self.modules_to_set,
122
- # opts_to_unset=opts_to_unset,
123
- # vars_to_set={'StepStart': step_start,
124
- # 'StepEnd': step_end,
125
- # 'DtSec': dt_sec,
126
- # 'PathOut': output_dir,
127
- # 'MapsCaching': 'True'})
128
- # lisfloodexe(settings)
129
- #
130
- # cache_size_a = Cache.size()
131
- # cache_found_a = Cache.values_found()
132
- # print('Cache size is {}'.format(cache_size_a))
133
- # print('Items found: {}'.format(cache_found_a))
134
- #
135
- # assert cache_found_a == 1 # apparently one map is called twice
136
- #
137
- # lisfloodexe(settings)
138
- #
139
- # cache_size_b = Cache.size()
140
- # cache_found_b = Cache.values_found()
141
- # print('Cache size is {}'.format(cache_size_b))
142
- # print('Items found: {}'.format(cache_found_b))
143
- #
144
- # Cache.info()
145
- #
146
- # assert cache_found_b == cache_size_b + 2
147
- # assert cache_size_a == cache_size_b
148
- #
149
- # self.compare_reference('dis', check='map', step_length=dt_sec)
150
- # self.compare_reference('dis', check='tss', step_length=dt_sec)
151
- # self.compare_reference('chanq', check='tss', step_length=dt_sec)
152
- #
153
- #
154
- # def test_dis_daily(self):
155
- # self.run('86400', '02/01/2016 06:00', '02/07/2016 06:00')
156
- #
157
- # def test_dis_6h(self):
158
- # self.run('21600', '02/01/2016 06:00', '02/07/2016 06:00')
159
- #
160
- # def teardown_method(self):
161
- # print('Cleaning directories and cache')
162
- # settings = LisSettings.instance()
163
- # output_dir = settings.output_dir
164
- # shutil.rmtree(output_dir)
165
- # Cache.clear()
86
+ @pytest .mark .slow
87
+ class TestCachingSlow (ETRS89TestCase ):
88
+ case_dir = os .path .join (os .path .dirname (__file__ ), 'data' , 'LF_ETRS89_UseCase' )
89
+
90
+ modules_to_set = (
91
+ 'SplitRouting' ,
92
+ 'simulateReservoirs' ,
93
+ 'simulateLakes' ,
94
+ 'drainedIrrigation' ,
95
+ 'openwaterevapo' ,
96
+ 'riceIrrigation' ,
97
+ 'wateruse' ,
98
+ 'useWaterDemandAveYear' ,
99
+ 'wateruseRegion' ,
100
+ 'TransientWaterDemandChange' ,
101
+ )
102
+ settings_files = {
103
+ 'base' : os .path .join (case_dir , 'settings/base.xml' ),
104
+ 'prerun' : os .path .join (case_dir , 'settings/prerun.xml' )
105
+ }
106
+
107
+ def run (self , dt_sec , step_start , step_end ):
108
+ output_dir = mk_path_out ('data/LF_ETRS89_UseCase/out/test_results{}' .format (dt_sec ))
109
+ opts_to_unset = (
110
+ "repStateSites" , "repRateSites" , "repStateUpsGauges" , "repRateUpsGauges" , "repMeteoUpsGauges" ,
111
+ "repsimulateLakes" , "repStateMaps" ,
112
+ "repsimulateReservoirs" , "repSnowMaps" , "repPFMaps" , "repLZMaps" , "repUZMaps" ,
113
+ "repGwPercUZLZMaps" , "repRWS" , "repTotalWUse" , "repWIndex" ,
114
+ "repSurfaceRunoffMaps" , "repRainMaps" , "repSnowMaps" , "repSnowCoverMaps" , "repSnowMeltMaps" , "repThetaMaps" ,
115
+ "repThetaForestMaps" , "repLZMaps" , "repUZMaps" ,
116
+ "repGwPercUZLZMaps" , "repRWS" , "repPFMaps" , "repPFForestMaps"
117
+ )
118
+ settings = setoptions (self .settings_files ['base' ],
119
+ opts_to_set = ('repDischargeTs' , 'repDischargeMaps' ,) + self .modules_to_set ,
120
+ opts_to_unset = opts_to_unset ,
121
+ vars_to_set = {'StepStart' : step_start ,
122
+ 'StepEnd' : step_end ,
123
+ 'DtSec' : dt_sec ,
124
+ 'PathOut' : output_dir ,
125
+ 'MapsCaching' : 'True' })
126
+ lisfloodexe (settings )
127
+
128
+ cache_size_a = Cache .size ()
129
+ cache_found_a = Cache .values_found ()
130
+ print ('Cache size is {}' .format (cache_size_a ))
131
+ print ('Items found: {}' .format (cache_found_a ))
132
+
133
+ assert cache_found_a == 1 # apparently one map is called twice
134
+
135
+ lisfloodexe (settings )
136
+
137
+ cache_size_b = Cache .size ()
138
+ cache_found_b = Cache .values_found ()
139
+ print ('Cache size is {}' .format (cache_size_b ))
140
+ print ('Items found: {}' .format (cache_found_b ))
141
+
142
+ Cache .info ()
143
+
144
+ assert cache_found_b == cache_size_b + 2
145
+ assert cache_size_a == cache_size_b
146
+
147
+ self .compare_reference ('dis' , check = 'map' , step_length = dt_sec )
148
+ self .compare_reference ('dis' , check = 'tss' , step_length = dt_sec )
149
+ self .compare_reference ('chanq' , check = 'tss' , step_length = dt_sec )
150
+
151
+
152
+ def test_dis_daily (self ):
153
+ self .run ('86400' , '02/01/2016 06:00' , '02/07/2016 06:00' )
154
+
155
+ def test_dis_6h (self ):
156
+ self .run ('21600' , '02/01/2016 06:00' , '02/07/2016 06:00' )
157
+
158
+ def teardown_method (self ):
159
+ print ('Cleaning directories and cache' )
160
+ settings = LisSettings .instance ()
161
+ output_dir = settings .output_dir
162
+ shutil .rmtree (output_dir )
163
+ Cache .clear ()
0 commit comments