|
@@ 100-107 (lines=8) @@
|
| 97 |
|
self.assertEqual(res[0].Value.Value, self.values[0]) |
| 98 |
|
|
| 99 |
|
# start time greater than end time, should return reverse order |
| 100 |
|
def test_history_read_5_in_timeframe_start_greater_than_end(self): |
| 101 |
|
now = datetime.utcnow() |
| 102 |
|
old = now - timedelta(days=6) |
| 103 |
|
|
| 104 |
|
res = self.var.read_raw_history(now, old, 5) |
| 105 |
|
self.assertEqual(len(res), 5) |
| 106 |
|
self.assertEqual(res[-1].Value.Value, self.values[-5]) |
| 107 |
|
self.assertEqual(res[0].Value.Value, self.values[-1]) |
| 108 |
|
|
| 109 |
|
# only start return original order |
| 110 |
|
def test_history_read_6_with_start(self): |
|
@@ 90-97 (lines=8) @@
|
| 87 |
|
self.assertEqual(res[-1].Value.Value, self.values[-1]) |
| 88 |
|
self.assertEqual(res[0].Value.Value, self.values[0]) |
| 89 |
|
|
| 90 |
|
def test_history_read_5_in_timeframe(self): |
| 91 |
|
now = datetime.utcnow() |
| 92 |
|
old = now - timedelta(days=6) |
| 93 |
|
|
| 94 |
|
res = self.var.read_raw_history(old, now, 5) |
| 95 |
|
self.assertEqual(len(res), 5) |
| 96 |
|
self.assertEqual(res[-1].Value.Value, self.values[4]) |
| 97 |
|
self.assertEqual(res[0].Value.Value, self.values[0]) |
| 98 |
|
|
| 99 |
|
# start time greater than end time, should return reverse order |
| 100 |
|
def test_history_read_5_in_timeframe_start_greater_than_end(self): |
|
@@ 81-88 (lines=8) @@
|
| 78 |
|
self.assertEqual(res[-1].Value.Value, self.values[-2]) |
| 79 |
|
|
| 80 |
|
# both start and endtime, return from start to end |
| 81 |
|
def test_history_read_all(self): |
| 82 |
|
now = datetime.utcnow() |
| 83 |
|
old = now - timedelta(days=6) |
| 84 |
|
|
| 85 |
|
res = self.var.read_raw_history(old, now, 0) |
| 86 |
|
self.assertEqual(len(res), 20) |
| 87 |
|
self.assertEqual(res[-1].Value.Value, self.values[-1]) |
| 88 |
|
self.assertEqual(res[0].Value.Value, self.values[0]) |
| 89 |
|
|
| 90 |
|
def test_history_read_5_in_timeframe(self): |
| 91 |
|
now = datetime.utcnow() |
|
@@ 119-125 (lines=7) @@
|
| 116 |
|
self.assertEqual(res[0].Value.Value, self.values[0]) |
| 117 |
|
|
| 118 |
|
# only start return original order |
| 119 |
|
def test_history_read_all_with_start(self): |
| 120 |
|
now = datetime.utcnow() |
| 121 |
|
old = now - timedelta(days=6) |
| 122 |
|
res = self.var.read_raw_history(old, None, 0) |
| 123 |
|
self.assertEqual(len(res), 20) |
| 124 |
|
self.assertEqual(res[-1].Value.Value, self.values[-1]) |
| 125 |
|
self.assertEqual(res[0].Value.Value, self.values[0]) |
| 126 |
|
|
| 127 |
|
# only end return reversed order |
| 128 |
|
def test_history_read_all_with_end(self): |
|
@@ 110-116 (lines=7) @@
|
| 107 |
|
self.assertEqual(res[0].Value.Value, self.values[-1]) |
| 108 |
|
|
| 109 |
|
# only start return original order |
| 110 |
|
def test_history_read_6_with_start(self): |
| 111 |
|
now = datetime.utcnow() |
| 112 |
|
old = now - timedelta(days=6) |
| 113 |
|
res = self.var.read_raw_history(old, None, 6) |
| 114 |
|
self.assertEqual(len(res), 6) |
| 115 |
|
self.assertEqual(res[-1].Value.Value, self.values[5]) |
| 116 |
|
self.assertEqual(res[0].Value.Value, self.values[0]) |
| 117 |
|
|
| 118 |
|
# only start return original order |
| 119 |
|
def test_history_read_all_with_start(self): |