Code Duplication    Length = 17-23 lines in 2 locations

annotation/tests.py 2 locations

@@ 200-222 (lines=23) @@
197
        self.assertEqual(response, expected)
198
199
200
    def test_upload(self):
201
        self.request.matchdict['table'] = 'mytable'
202
        self.request.params['id'] = '355'
203
        self.request.params['start'] = '2010-06-27T00:00:00+00:00'
204
        self.request.params['end'] = '2010-06-29T00:00:00+00:00'
205
        self.config.add_route('annotations.csv', '/uploads/{table}/annotations.csv')
206
        views = UploadViews(self.request)
207
        rows = [{
208
                 'id': 3,
209
                 'label': 'flying',
210
                 'color': 'rgb(0,0,255)',
211
                 }]
212
        self.cursor.fetchall.return_value = rows
213
214
        response = views.upload()
215
216
        expected_response = {'annotations_url': '/uploads/mytable/annotations.csv',
217
                             'classes': '[{"color": "rgb(0,0,255)", "id": 3, "label": "flying"}]',
218
                             'end': '2010-06-29T00:00:00+00:00',
219
                             'start': '2010-06-27T00:00:00+00:00',
220
                             'tracker_id': 355,
221
                             }
222
        self.assertEqual(response, expected_response)
223
224
    def test_upload_withoutselection(self):
225
        self.request.matchdict['table'] = 'mytable'
@@ 235-251 (lines=17) @@
232
        self.assertIsInstance(response, HTTPFound)
233
        self.assertEqual(response.location, expected_response.location)
234
235
    def test_annotations_as_csv(self):
236
        self.request.matchdict['table'] = 'mytable'
237
        self.request.params['id'] = '355'
238
        self.request.params['start'] = '2010-06-27T00:00:00+00:00'
239
        self.request.params['end'] = '2010-06-29T00:00:00+00:00'
240
        views = UploadViews(self.request)
241
        rows = [{
242
                 'device_info_serial': 355,
243
                 'date_time': datetime(2010, 6, 28, 0, 0, 0, 0, UTC),
244
                 'class_id': 3
245
                 }]
246
        self.cursor.fetchall.return_value = rows
247
248
        response = views.annotations_as_csv()
249
250
        expected_body = 'device_info_serial,date_time,class_id\n355,2010-06-28T00:00:00+00:00Z,3\n'
251
        self.assertEqual(response.body, expected_body)
252