Skip to content

Commit

Permalink
moved missing city test to cities_test
Browse files Browse the repository at this point in the history
  • Loading branch information
jwaiton committed Feb 19, 2024
1 parent 228a466 commit 625e012
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 32 deletions.
31 changes: 30 additions & 1 deletion invisible_cities/cities/cities_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@

import tables as tb

from pytest import mark
from pytest import mark, raises

from .. core.configure import configure

some_cities = "irene dorothea penthesilea esmeralda beersheba".split()

db_cities = """beersheba sophronia berenice buffy detsim
diomira dorothea esmeralda eutropia hypathia
irene isaura isidora penthesilea phyllis trude""".split()

all_cities = """beersheba berenice buffy detsim diomira dorothea esmeralda
eutropia hypathia irene isaura isidora penthesilea phyllis
trude""".split()
Expand Down Expand Up @@ -57,3 +62,27 @@ def test_city_output_file_is_compressed(config_tmpdir, ICDATADIR, city):

except tb.NoSuchNodeError:
continue



@mark.filterwarnings("ignore::UserWarning")
@mark.parametrize("city", db_cities)
def test_city_missing_detector_db(city):

# use default config file
config_file = 'dummy invisible_cities/config/{}.conf'.format(city)
conf = configure(config_file.split())

# delete the detector_db key from the config
del conf['detector_db']

# collect relevant city information for running
module_name = f'invisible_cities.cities.{city}'
city_function = getattr(import_module(module_name), city)


# check that the test provides the
# required value error for missing detector_db
with raises(ValueError, match=r"The function `(\w+)` is missing an argument `detector_db`"):
city_function(**conf)

31 changes: 0 additions & 31 deletions invisible_cities/cities/db_test.py

This file was deleted.

0 comments on commit 625e012

Please sign in to comment.