示例#1
0
文件: views.py 项目: nadvamir/gofish
def getData(request):
    qs = DataPoint.query(
        username  = request.GET.get('username', None),
        gameNum   = request.GET.get('gameNum', None),
        cueDetail = request.GET.get('cueDetail', None),
        level     = request.GET.get('level', None),
        moveCost  = request.GET.get('moveCost', None),
        endGame   = request.GET.get('endGame', None))

    response = {'data': [el.toDict() for el in qs]}
    return HttpResponse(json.dumps(response), content_type="application/json")
示例#2
0
 def test_add_data_point(self):
     Node(node_id='TEST').put()
     data_point_json = {
         'node_id': 'TEST',
         'temperature': 50,
         'humidity': 40,
         'pressure': 34,
         'light': 14,
         'saturation': 12,
     }
     response = self.app.post_json('/datapoint/', data_point_json)
     self.assertEqual(201, response.status_code)
     self.assertEqual(
         {'status': 'success'},
         json.loads(response.body))
     self.assertEqual(1, DataPoint.query().count())