Skip to content

Commit d46933b

Browse files
committed
cleaning up tests
1 parent 0f6ce72 commit d46933b

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

google_symptoms/tests/conftest.py

Lines changed: 5 additions & 5 deletions
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",
@@ -105,12 +105,12 @@ def params_w_patch(params):
105105

106106
@pytest.fixture(scope="session")
107107
def run_as_module(params):
108-
if exists("receiving"):
108+
if exists(f"{TEST_DIR}/receiving"):
109109
# Clean receiving directory
110-
for fname in listdir("receiving"):
111-
remove(join("receiving", fname))
110+
for fname in listdir(f"{TEST_DIR}/receiving"):
111+
remove(join(f"{TEST_DIR}/receiving", fname))
112112
else:
113-
makedirs("receiving")
113+
makedirs(f"{TEST_DIR}/receiving")
114114

115115
with mock.patch("delphi_google_symptoms.pull.initialize_credentials",
116116
return_value=None) as mock_credentials:

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: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
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+
17+
def test_output_files_exist(self, run_as_module):
18+
output_files = listdir(f"{TEST_DIR}/receiving")
1419
smoothed_files = sorted(list(set([file for file in output_files if "smoothed" in file])))
1520
raw_files = sorted(list(set([file for file in output_files if "raw" in file])))
1621
csv_files = {"raw": raw_files, "smoothed": smoothed_files}
@@ -62,11 +67,10 @@ def test_output_files_exist(self):
6267
csv_dates = list(set([datetime.strptime(f.split('_')[0], "%Y%m%d") for f in csv_files[smther] if smther in f]))
6368
assert set(csv_files[smther]).issuperset(set(expected_files))
6469

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

67-
def test_output_file_format(self, run_as_module):
71+
def test_output_file_format(self):
6872
df = pd.read_csv(
69-
join("receiving", "20200810_state_s03_smoothed_search.csv")
73+
join(f"{TEST_DIR}/receiving", "20200810_state_s03_smoothed_search.csv")
7074
)
7175
assert (df.columns.values == [
7276
"geo_id", "val", "se", "sample_size"]).all()

0 commit comments

Comments
 (0)