-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_pill_calendar.py
186 lines (175 loc) · 8.62 KB
/
test_pill_calendar.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import collections
import pytest
import pill_calendar as pc
class TestPillCalendar:
@classmethod
def setup_class(cls):
pass
def test_loadCalendar(self):
''' Test that we properly load data from CSV
'''
cal_file = './test_files/Calendar.csv'
data = pc.loadCalendar(cal_file)
expected_data = [{'event_id': 'aaaaaaaaaaaaaaaaaaaaaaaaaa',
'description': 'Coumadin Amount: 2',
'end_datetime': '2013-07-07T20:15:00Z',
'start_datetime': '2013-07-07T18:45:00Z',
'summary': 'Coumadin Amount: 2'},
{'event_id': 'bbbbbbbbbbbbbbbbbbbbbbbbbb',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-06T20:15:00Z',
'start_datetime': '2013-07-06T18:45:00Z',
'summary': 'Coumadin Amount: 1'},
{'event_id': 'cccccccccccccccccccccccccc',
'description': 'Blood Level: 2.2',
'end_datetime': '2013-07-07T10:00:00Z',
'start_datetime': '2013-07-07T09:15:00Z',
'summary': 'Blood Level: 2.2'},
{'event_id': 'dddddddddddddddddddddddddd',
'description': 'Test Blood',
'end_datetime': '2013-07-14T10:00:00Z',
'start_datetime': '2013-07-14T09:15:00Z',
'summary': 'Test Blood'}]
assert data == expected_data
def test_getEntries(self):
''' Test that we properly load data from CSV
'''
cal_file = './test_files/Calendar.csv'
data = pc.getEntries(pc.loadCalendar(cal_file), 'Pills')
expected_data = [{'event_id': 'aaaaaaaaaaaaaaaaaaaaaaaaaa',
'description': 'Coumadin Amount: 2',
'end_datetime': '2013-07-07T20:15:00Z',
'start_datetime': '2013-07-07T18:45:00Z',
'summary': 'Coumadin Amount: 2'},
{'event_id': 'bbbbbbbbbbbbbbbbbbbbbbbbbb',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-06T20:15:00Z',
'start_datetime': '2013-07-06T18:45:00Z',
'summary': 'Coumadin Amount: 1'}]
assert data == expected_data
data = pc.getEntries(pc.loadCalendar(cal_file), 'Blood Level')
expected_data = [{'event_id': 'cccccccccccccccccccccccccc',
'description': 'Blood Level: 2.2',
'end_datetime': '2013-07-07T10:00:00Z',
'start_datetime': '2013-07-07T09:15:00Z',
'summary': 'Blood Level: 2.2'},
{'event_id': 'dddddddddddddddddddddddddd',
'description': 'Test Blood',
'end_datetime': '2013-07-14T10:00:00Z',
'start_datetime': '2013-07-14T09:15:00Z',
'summary': 'Test Blood'}]
assert data == expected_data
def test_mergeEntries(self):
''' Test that we properly merge newly generated data into
existing data
'''
# Merging exact same 2 dates
cal_file = './test_files/Calendar.csv'
data_set = pc.getEntries(pc.loadCalendar(cal_file), 'Pills')
new_entries = pc.createEntries('06/07/2013', 2, [1,1])
merged = pc.mergeEntries(data_set, new_entries)
expected_data = [{'event_id': 'aaaaaaaaaaaaaaaaaaaaaaaaaa',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-07T20:15:00Z',
'start_datetime': '2013-07-07T18:45:00Z',
'summary': 'Coumadin Amount: 1'},
{'event_id': 'bbbbbbbbbbbbbbbbbbbbbbbbbb',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-06T20:15:00Z',
'start_datetime': '2013-07-06T18:45:00Z',
'summary': 'Coumadin Amount: 1'}]
assert merged == expected_data
# Merging bc into ab
cal_file = './test_files/Calendar.csv'
data_set = pc.getEntries(pc.loadCalendar(cal_file), 'Pills')
new_entries = pc.createEntries('07/07/2013', 2, [1,1])
merged = pc.mergeEntries(data_set, new_entries)
expected_data = [{'event_id': 'bbbbbbbbbbbbbbbbbbbbbbbbbb',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-06T20:15:00Z',
'start_datetime': '2013-07-06T18:45:00Z',
'summary': 'Coumadin Amount: 1'},
{'event_id': 'aaaaaaaaaaaaaaaaaaaaaaaaaa',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-07T20:15:00Z',
'start_datetime': '2013-07-07T18:45:00Z',
'summary': 'Coumadin Amount: 1'},
{'event_id': '',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-08T20:15:00Z',
'start_datetime': '2013-07-08T18:45:00Z',
'summary': 'Coumadin Amount: 1'}]
assert merged == expected_data
# Merging ab into bc
cal_file = './test_files/Calendar.csv'
data_set = pc.getEntries(pc.loadCalendar(cal_file), 'Pills')
new_entries = pc.createEntries('05/07/2013', 2, [1,1])
merged = pc.mergeEntries(data_set, new_entries)
expected_data = [{'event_id': 'aaaaaaaaaaaaaaaaaaaaaaaaaa',
'description': 'Coumadin Amount: 2',
'end_datetime': '2013-07-07T20:15:00Z',
'start_datetime': '2013-07-07T18:45:00Z',
'summary': 'Coumadin Amount: 2'},
{'event_id': 'bbbbbbbbbbbbbbbbbbbbbbbbbb',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-06T20:15:00Z',
'start_datetime': '2013-07-06T18:45:00Z',
'summary': 'Coumadin Amount: 1'},
{'event_id': '',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-05T20:15:00Z',
'start_datetime': '2013-07-05T18:45:00Z',
'summary': 'Coumadin Amount: 1'}]
assert merged == expected_data
# Merging ef into ab
cal_file = './test_files/Calendar.csv'
data_set = pc.getEntries(pc.loadCalendar(cal_file), 'Pills')
new_entries = pc.createEntries('15/07/2013', 2, [1,1])
merged = pc.mergeEntries(data_set, new_entries)
expected_data = [{'event_id': 'aaaaaaaaaaaaaaaaaaaaaaaaaa',
'description': 'Coumadin Amount: 2',
'end_datetime': '2013-07-07T20:15:00Z',
'start_datetime': '2013-07-07T18:45:00Z',
'summary': 'Coumadin Amount: 2'},
{'event_id': 'bbbbbbbbbbbbbbbbbbbbbbbbbb',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-06T20:15:00Z',
'start_datetime': '2013-07-06T18:45:00Z',
'summary': 'Coumadin Amount: 1'},
{'event_id': '',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-15T20:15:00Z',
'start_datetime': '2013-07-15T18:45:00Z',
'summary': 'Coumadin Amount: 1'},
{'event_id': '',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-16T20:15:00Z',
'start_datetime': '2013-07-16T18:45:00Z',
'summary': 'Coumadin Amount: 1'}]
assert merged == expected_data
# Merging ab into ef
cal_file = './test_files/Calendar.csv'
data_set = pc.getEntries(pc.loadCalendar(cal_file), 'Pills')
new_entries = pc.createEntries('01/07/2013', 2, [1,1])
merged = pc.mergeEntries(data_set, new_entries)
expected_data = [{'event_id': 'aaaaaaaaaaaaaaaaaaaaaaaaaa',
'description': 'Coumadin Amount: 2',
'end_datetime': '2013-07-07T20:15:00Z',
'start_datetime': '2013-07-07T18:45:00Z',
'summary': 'Coumadin Amount: 2'},
{'event_id': 'bbbbbbbbbbbbbbbbbbbbbbbbbb',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-06T20:15:00Z',
'start_datetime': '2013-07-06T18:45:00Z',
'summary': 'Coumadin Amount: 1'},
{'event_id': '',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-01T20:15:00Z',
'start_datetime': '2013-07-01T18:45:00Z',
'summary': 'Coumadin Amount: 1'},
{'event_id': '',
'description': 'Coumadin Amount: 1',
'end_datetime': '2013-07-02T20:15:00Z',
'start_datetime': '2013-07-02T18:45:00Z',
'summary': 'Coumadin Amount: 1'}]
assert merged == expected_data