def test_upload(self): self.request.matchdict['table'] = 'mytable' self.request.params['id'] = '355' self.request.params['start'] = '2010-06-27T00:00:00+00:00' self.request.params['end'] = '2010-06-29T00:00:00+00:00' self.config.add_route('annotations.csv', '/uploads/{table}/annotations.csv') views = UploadViews(self.request) rows = [{ 'id': 3, 'label': 'flying', 'color': 'rgb(0,0,255)', }] self.cursor.fetchall.return_value = rows response = views.upload() expected_response = { 'annotations_url': '/uploads/mytable/annotations.csv', 'classes': '[{"color": "rgb(0,0,255)", "id": 3, "label": "flying"}]', 'end': '2010-06-29T00:00:00+00:00', 'start': '2010-06-27T00:00:00+00:00', 'tracker_id': 355, } self.assertEqual(response, expected_response)
def test_upload_withoutselection(self): self.request.matchdict['table'] = 'mytable' self.config.add_route('uploads.html', '/uploads.html') views = UploadViews(self.request) response = views.upload() expected_response = HTTPFound('/uploads.html?table=mytable') self.assertIsInstance(response, HTTPFound) self.assertEqual(response.location, expected_response.location)
def test_upload(self): self.request.matchdict['table'] = 'mytable' self.request.params['id'] = '355' self.request.params['start'] = '2010-06-27T00:00:00+00:00' self.request.params['end'] = '2010-06-29T00:00:00+00:00' self.config.add_route('annotations.csv', '/uploads/{table}/annotations.csv') views = UploadViews(self.request) rows = [{ 'id': 3, 'label': 'flying', 'color': 'rgb(0,0,255)', }] self.cursor.fetchall.return_value = rows response = views.upload() expected_response = {'annotations_url': '/uploads/mytable/annotations.csv', 'classes': '[{"color": "rgb(0,0,255)", "id": 3, "label": "flying"}]', 'end': '2010-06-29T00:00:00+00:00', 'start': '2010-06-27T00:00:00+00:00', 'tracker_id': 355, } self.assertEqual(response, expected_response)