-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest_retraction.py
97 lines (82 loc) · 2.46 KB
/
test_retraction.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import pandas as pd
import pytest
from genie_registry.sampleRetraction import sampleRetraction
from genie_registry.patientRetraction import patientRetraction
@pytest.fixture
def sr(syn):
return sampleRetraction(syn, "SAGE")
@pytest.fixture
def pr(syn):
return patientRetraction(syn, "SAGE")
def test_processing(sr, pr):
expectedsrDf = pd.DataFrame(
dict(
genieSampleId=[
"GENIE-SAGE-ID1-1",
"GENIE-SAGE-ID2-1",
"GENIE-SAGE-ID3-1",
"GENIE-SAGE-ID4-1",
"GENIE-SAGE-ID5-1",
],
retractionDate=[
1523039400000,
1523039400000,
1523039400000,
1523039400000,
1523039400000,
],
center=["SAGE", "SAGE", "SAGE", "SAGE", "SAGE"],
)
)
srDf = pd.DataFrame(
{
0: [
"GENIE-SAGE-ID1-1",
"GENIE-SAGE-ID2-1",
"GENIE-SAGE-ID3-1",
"GENIE-SAGE-ID4-1",
"GENIE-SAGE-ID5-1",
]
}
)
newsrDf = sr._process(srDf, "2018-04-06T18:30:00")
assert expectedsrDf.equals(newsrDf[expectedsrDf.columns])
expectedprDf = pd.DataFrame(
dict(
geniePatientId=[
"GENIE-SAGE-ID1",
"GENIE-SAGE-ID2",
"GENIE-SAGE-ID3",
"GENIE-SAGE-ID4",
"GENIE-SAGE-ID5",
],
retractionDate=[
1523125800000,
1523125800000,
1523125800000,
1523125800000,
1523125800000,
],
center=["SAGE", "SAGE", "SAGE", "SAGE", "SAGE"],
)
)
prDf = pd.DataFrame(
{
0: [
"GENIE-SAGE-ID1",
"GENIE-SAGE-ID2",
"GENIE-SAGE-ID3",
"GENIE-SAGE-ID4",
"GENIE-SAGE-ID5",
]
}
)
newprDf = pr._process(prDf, "2018-04-07T18:30:00")
assert expectedprDf.equals(newprDf[expectedprDf.columns])
def test_validate_filename(sr, pr):
with pytest.raises(AssertionError):
sr.validateFilename(["foo"])
assert sr.validateFilename(["sampleRetraction.csv"]) == "sampleRetraction"
with pytest.raises(AssertionError):
pr.validateFilename(["foo"])
assert pr.validateFilename(["patientRetraction.csv"]) == "patientRetraction"