def test_query_user(self): q = Query('0%user') result = q.send_request() user0_file = open('json/user0.json', 'r') user0_data = json.load(user0_file) user0_file.close() self.assertEqual(result['user'], user0_data)
def test_query_route(self): q = Query('0%route') result = q.send_request() route0_file = open('json/route0.json', 'r') route0_data = json.load(route0_file) route0_file.close() self.assertEqual(result['route'], route0_data)
def test_hardest(self): q = Query('0%hardest') result = q.send_request() route_file = open('json/route0.json', 'r') route_data = json.load(route_file) self.assertEqual(result['hardest']['boulder'], route_data) route_file.close()
def test_unpopular(self): q = Query('0+1%unpopular') result = q.send_request() route0_file = open('json/route0.json', 'r') route0_data = json.load(route0_file) route0_file.close() route1_file = open('json/route1.json', 'r') route1_data = json.load(route1_file) route1_file.close() self.assertEqual(result['unpopular'][0], route0_data) self.assertEqual(result['unpopular'][1], route1_data)
def exec_query(query_str: str): try: q = Query(query_str) return jsonify(q.send_request()) except: return make_response(jsonify({'error': 'Bad request'}), 400)
def test_tick_failure(self): q = Query('0+1%tick') result = q.send_request() self.assertEqual(len(result['tick']), 0)
def test_todo_success(self): q = Query('0+1%todo') result = q.send_request() self.assertEqual(len(result['todo']), 1)
def test_all(self): q = Query('200305518+200696013%all') result = q.send_request() pprint(result)