Code Duplication    Length = 7-8 lines in 5 locations

tests/tests_history.py 5 locations

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