-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from jdkent/add_logging
[ENH] add logging system to write results to files
- Loading branch information
Showing
7 changed files
with
155 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
import pandas as pd | ||
|
||
|
||
class MockProject: | ||
|
||
def __init__(self, url, key): | ||
pass | ||
|
||
@staticmethod | ||
def export_records(fields, records=None, format='df'): | ||
test_path = os.path.dirname(os.path.realpath(__file__)) | ||
if "extend_id" in fields: | ||
mock_file = "mock_redcap_extend.tsv" | ||
elif "better_id" in fields: | ||
mock_file = "mock_redcap_better.tsv" | ||
elif "bike_id" in fields: | ||
mock_file = "mock_redcap_bikeatrain.tsv" | ||
elif "ambi_id" in fields: | ||
mock_file = "mock_redcap_ambi.tsv" | ||
elif "pacr_id" in fields: | ||
mock_file = "mock_redcap_pacr.tsv" | ||
elif "alertid" in fields: | ||
mock_file = "mock_redcap_alert.tsv" | ||
elif "normative_id" in fields: | ||
mock_file = "mock_redcap_normative.tsv" | ||
else: | ||
raise ValueError("project not found!") | ||
|
||
df = pd.read_csv(os.path.join(test_path, | ||
"data", | ||
"mock_redcap", | ||
mock_file), | ||
sep="\t", index_col="lab_id") | ||
return df |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import os | ||
import sys | ||
|
||
import redcap | ||
|
||
from .conftest import MockProject | ||
from ..run import main | ||
|
||
|
||
def test_main(monkeypatch): | ||
|
||
# patch the redcap project | ||
monkeypatch.setattr(redcap, "Project", MockProject) | ||
|
||
project_root_directory = os.path.join( | ||
os.path.dirname(__file__), | ||
'data', | ||
'vosslabhpc', | ||
) | ||
|
||
old_file_path = os.path.join( | ||
os.path.dirname(__file__), | ||
'data', | ||
'827 (2018-11-29)RAW.csv', | ||
) | ||
|
||
api_key = 'fake_api_key' | ||
|
||
excel_file_path = os.path.join( | ||
os.path.dirname(__file__), | ||
'data', | ||
'ActiGraph_analysis_summary.xlsx', | ||
) | ||
|
||
logging_directory = os.path.join( | ||
os.path.dirname(__file__), | ||
'data', | ||
) | ||
|
||
args = [ | ||
"accel_transform", | ||
project_root_directory, | ||
old_file_path, | ||
api_key, | ||
excel_file_path, | ||
"--logging-directory", logging_directory, | ||
"--replace", "yes", | ||
] | ||
|
||
# pass arguments to be parsed by main | ||
monkeypatch.setattr(sys, 'argv', args) | ||
|
||
assert main() is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters