-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_filekit.py
49 lines (37 loc) · 1.15 KB
/
test_filekit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import pytest
from filekit import find_files, process_files
import shutil
test_data = '''
'id','avg_hr_min','avg_hr_hour','pk_hr','low_hr'
1,60.7,360,78,71
2,70.0,330,80,58
3,72.2,350,82,78
6,61.8,300,70,63
'''
@pytest.fixture(scope="module", autouse=True)
def build_test_dir():
# setup before each test
if 'test' in os.listdir('.'):
shutil.rmtree('test')
os.mkdir('test')
os.mkdir('test/subjects')
os.mkdir('test/subjects/heart_data')
os.mkdir('test/subjects/sleep_data')
with open('test/subjects/heart_data/123_heart.csv','w+') as fh:
fh.write(test_data)
with open('test/subjects/sleep_data/123_sleep.csv','w+') as fh:
fh.write(test_data)
# test is run
yield
if 'test' in os.listdir('.'):
shutil.rmtree('test')
def test_find_files_defaults():
os.chdir('test')
base_path = os.path.abspath(os.curdir)
test_filepaths = [
os.path.join(base_path,'subjects/heart_data/123_heart.csv'),
os.path.join(base_path,'subjects/sleep_data/123_sleep.csv')
]
results = find_files()
assert str(sorted(results['results'])) == str(sorted(test_filepaths))