-
Notifications
You must be signed in to change notification settings - Fork 5
/
tests.py
40 lines (28 loc) · 1.64 KB
/
tests.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
import unittest
import pandas
from ecobee_config import EcobeeConfig
from ecobee_csv import EcobeeCSV
class EcobeeTest(unittest.TestCase):
def test_no_thermostat_column(self):
# Previous versions didn't include thermostat id, need to handle that
existing_df = pandas.read_csv("test/no-thermostat-id.csv")
updated_df = pandas.read_csv("test/updated.csv")
df = EcobeeCSV.update_data(existing_df, updated_df)
# Check update
self.assertEqual(df.filter(items=[(456,"2022-07-07","19:55:00")], axis=0).shape[0], 1)
self.assertEqual(df["Cool Stage 1 (sec)"].filter(items=[(456,"2022-07-07","19:55:00")], axis=0).values[0], 250)
# Check merge
self.assertEqual(df.filter(items=[(456,"2022-07-08","00:55:00")], axis=0).shape[0], 1)
self.assertEqual(df.filter(items=[(456,"2022-07-08","00:55:00")], axis=0)["Cool Stage 1 (sec)"].values[0], 250)
def test_overwrite_values(self):
existing_df = pandas.read_csv("test/thermostat-id.csv")
updated_df = pandas.read_csv("test/updated.csv")
df = EcobeeCSV.update_data(existing_df, updated_df)
# Check update
self.assertEqual(df.filter(items=[(456,"2022-07-07","19:55:00")], axis=0).shape[0], 1)
self.assertEqual(df["Cool Stage 1 (sec)"].filter(items=[(456,"2022-07-07","19:55:00")], axis=0).values[0], 250)
# Check merge
self.assertEqual(df.filter(items=[(456,"2022-07-08","00:55:00")], axis=0).shape[0], 1)
self.assertEqual(df.filter(items=[(456,"2022-07-08","00:55:00")], axis=0)["Cool Stage 1 (sec)"].values[0], 250)
if __name__ == "__main__":
unittest.main()