Skip to content

Commit 764f581

Browse files
committed
cleaning up tests
1 parent 0f6ce72 commit 764f581

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

google_symptoms/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def logger():
7272
def params():
7373
params = {
7474
"common": {
75-
"export_dir": "./receiving"
75+
"export_dir": f"{TEST_DIR}/receiving"
7676
},
7777
"indicator": {
7878
"export_start_date": "2020-02-20",

google_symptoms/tests/test_patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def side_effect(*args, **kwargs):
5454
mock_read_gbq.side_effect = side_effect
5555
start_date = datetime.strptime(params_w_patch["patch"]["start_issue"], "%Y-%m-%d")
5656

57-
# patch()
57+
patch()
5858

5959
patch_path = Path(f"{TEST_DIR}/{params_w_patch['patch']['patch_dir']}")
6060

google_symptoms/tests/test_run.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
from conftest import TEST_DIR
1010

1111
class TestRun:
12-
def test_output_files_exist(self):
13-
output_files = listdir("receiving")
12+
@classmethod
13+
def teardown_class(cls):
14+
print('cleaning up tests...')
15+
shutil.rmtree(f"{TEST_DIR}/receiving/")
16+
def test_output_files_exist(self, run_as_module):
17+
output_files = listdir(f"{TEST_DIR}/receiving")
1418
smoothed_files = sorted(list(set([file for file in output_files if "smoothed" in file])))
1519
raw_files = sorted(list(set([file for file in output_files if "raw" in file])))
1620
csv_files = {"raw": raw_files, "smoothed": smoothed_files}
@@ -62,11 +66,10 @@ def test_output_files_exist(self):
6266
csv_dates = list(set([datetime.strptime(f.split('_')[0], "%Y%m%d") for f in csv_files[smther] if smther in f]))
6367
assert set(csv_files[smther]).issuperset(set(expected_files))
6468

65-
shutil.rmtree(f"{TEST_DIR}/receiving/")
6669

67-
def test_output_file_format(self, run_as_module):
70+
def test_output_file_format(self):
6871
df = pd.read_csv(
69-
join("receiving", "20200810_state_s03_smoothed_search.csv")
72+
join(f"{TEST_DIR}/receiving", "20200810_state_s03_smoothed_search.csv")
7073
)
7174
assert (df.columns.values == [
7275
"geo_id", "val", "se", "sample_size"]).all()

0 commit comments

Comments
 (0)