6262 (pathlib .Path ("#test.yml" ), DUMMY_STREAM_CONF ),
6363]
6464
65+ DUMMY_BASE_CONF = {
66+ # TODO add base configuration
67+ }
68+
6569
6670def contains_keys (super_config , sub_config ):
6771 keys_present = [key in super_config .keys () for key in sub_config .keys ()]
@@ -152,6 +156,17 @@ def config_fresh(private_config_file):
152156
153157 return cf
154158
159+ @pytest .fixture
160+ def base_conf ():
161+ return OmegaConf .create (DUMMY_BASE_CONF )
162+
163+ @pytest .fixure
164+ def base_file (base_conf ):
165+ with tempfile .NamedTemporaryFile ("w+" ) as temp :
166+ temp .write (OmegaConf .to_yaml (base_conf ))
167+ temp .flush ()
168+ yield pathlib .Path (temp .name )
169+
155170
156171def test_contains_private (config_fresh ):
157172 sanitized_private_conf = DUMMY_PRIVATE_CONF .copy ()
@@ -167,22 +182,35 @@ def test_is_paths_set(config_fresh):
167182
168183@pytest .mark .parametrize ("overwrite_dict" , DUMMY_OVERWRITES , indirect = True )
169184def test_load_with_overwrite_dict (overwrite_dict , private_config_file ):
170- cf = config .load_merge_configs (private_config_file , None , None , overwrite_dict )
185+ cf = config .load_merge_configs (private_config_file , None , None , None , overwrite_dict )
171186
172187 assert contains (cf , overwrite_dict )
173188
174189
175190@pytest .mark .parametrize ("overwrite_dict" , DUMMY_OVERWRITES , indirect = True )
176191def test_load_with_overwrite_config (overwrite_config , private_config_file ):
177- cf = config .load_merge_configs (private_config_file , None , None , overwrite_config )
192+ cf = config .load_merge_configs (private_config_file , None , None , None , overwrite_config )
178193
179194 assert contains (cf , overwrite_config )
180195
181196
182197@pytest .mark .parametrize ("overwrite_dict" , DUMMY_OVERWRITES , indirect = True )
183198def test_load_with_overwrite_file (private_config_file , overwrite_file ):
184199 sub_cf = OmegaConf .load (overwrite_file )
185- cf = config .load_merge_configs (private_config_file , None , None , overwrite_file )
200+ cf = config .load_merge_configs (private_config_file , None , None , None , overwrite_file )
201+
202+ assert contains (cf , sub_cf )
203+
204+
205+ def test_load_with_base_config (base_config , private_config_file ):
206+ cf = config .load_merge_configs (private_config_file , None , None , base_config )
207+
208+ assert contains (cf , base_config )
209+
210+
211+ def test_load_with_base_file (base_config_file , private_config_file ):
212+ sub_cf = OmegaConf .load (overwrite_file )
213+ cf = config .load_merge_configs (private_config_file , None , None , base_config_file )
186214
187215 assert contains (cf , sub_cf )
188216
@@ -191,7 +219,7 @@ def test_load_with_stream_in_overwrite(private_config_file, streams_dir, mocker)
191219 overwrite = {"streams_directory" : streams_dir }
192220 stub = mocker .patch ("weathergen.common.config.load_streams" , return_value = streams_dir )
193221
194- config .load_merge_configs (private_config_file , None , None , overwrite )
222+ config .load_merge_configs (private_config_file , None , None , None , overwrite )
195223
196224 stub .assert_called_once_with (streams_dir )
197225
@@ -200,7 +228,7 @@ def test_load_multiple_overwrites(private_config_file):
200228 overwrites = [{"foo" : 1 , "bar" : 1 , "baz" : 1 }, {"foo" : 2 , "bar" : 2 }, {"foo" : 3 }]
201229
202230 expected = {"foo" : 3 , "bar" : 2 , "baz" : 1 }
203- cf = config .load_merge_configs (private_config_file , None , None , * overwrites )
231+ cf = config .load_merge_configs (private_config_file , None , None , None , * overwrites )
204232
205233 assert contains (cf , expected )
206234
0 commit comments