def test_excel_file(self): data = {'url': 'http://0.0.0.0:50001/static/simple.xls', 'format': 'xls', 'id': 'uuid2'} context = {'webstore_url': 'http://0.0.0.0:50002', 'site_url': 'http://0.0.0.0:50001', 'apikey': 'test', 'username': '******'} tasks.webstorer_upload(json.dumps(context), json.dumps(data)) response = requests.get('http://0.0.0.0:50002/test/uuid2/data.json') assert json.loads(response.content) == [{u'date': u'2011-01-01T00:00:00', u'place': u'Galway', u'__id__': 1, u'temperature': 1}, {u'date': u'2011-01-02T00:00:00', u'place': u'Galway', u'__id__': 2, u'temperature': -1}, {u'date': u'2011-01-03T00:00:00', u'place': u'Galway', u'__id__': 3, u'temperature': 0}, {u'date': u'2011-01-01T00:00:00', u'place': u'Berkeley', u'__id__': 4, u'temperature': 6}, {u'date': u'2011-01-02T00:00:00', u'place': u'Berkeley', u'__id__': 5, u'temperature': 8}, {u'date': u'2011-01-03T00:00:00', u'place': u'Berkeley', u'__id__': 6, u'temperature': 5}], json.loads(response.content) response = requests.get('http://0.0.0.0:50001/last_request') assert json.loads(response.content)['headers'] == {u'Content-Length': u'126', u'Accept-Encoding': u'gzip', u'Connection': u'close', u'User-Agent': u'python-requests.org', u'Host': u'0.0.0.0:50001', u'Content-Type': u'application/json', u'Authorization': u'test'} assert json.loads(response.content)['data']['id'] == 'uuid2' assert json.loads(response.content)['data']['webstore_url'] == 'http://0.0.0.0:50002/test/uuid2/data'
def test_messier_file(self): file_path = os.path.join(os.path.dirname(__file__), "3ffdcd42-5c63-4089-84dd-c23876259973") data = {'url': 'http://0.0.0.0:50001/static/3ffdcd42-5c63-4089-84dd-c23876259973', 'format': 'csv', 'id': 'uuid3'} context = {'webstore_url': 'http://0.0.0.0:50002', 'site_url': 'http://0.0.0.0:50001', 'apikey': 'test', 'username': '******'} tasks.webstorer_upload(json.dumps(context), json.dumps(data)) response = requests.get('http://0.0.0.0:50002/test/uuid3/data.json') assert json.loads(response.content)[:3] == [ {u'Date': u'01/04/2009', u'Transaction Number': 136980, u'Amount': 2840.5, u'Expense Area': u'HOUSING HEALTH + COMMUNITY SAFETY', u'__id__': 1, u'Supplier': u'B H HAYES + SONS', u'Body Name': u'Adur District Council'}, {u'Date': u'01/04/2009', u'Transaction Number': 139471, u'Amount': 997.80999999999995, u'Expense Area': u'STRATEGIC PERFORMANCE,HR&TRANSFORMATION', u'__id__': 2, u'Supplier': u'BADENOCH + CLARK', u'Body Name': u'Adur District Council'}, {u'Date': u'01/04/2009', u'Transaction Number': 139723, u'Amount': 356.39999999999998, u'Expense Area': u'RECYCLING & WASTE DIVISION', u'__id__': 3, u'Supplier': u'B-O-S RECRUITMENT SERVICES', u'Body Name': u'Adur District Council'}], json.loads(response.content)[:3]