Exemplo n.º 1
0
 def testSucceeded(self):
     keys = Data.fetchByField("a")
     self.assertEqual(len(keys), 0)
     response = self.testapp.get("/post?a=bb&c=dd&a=x")
     self.assertEqual(json.loads(response.body), [{"dataId": 4, "field": "a", "string": "bb"},
                                                  {"dataId": 5, "field": "a", "string": "x"},
                                                  {"dataId": 6, "field": "c", "string": "dd"}])
     keys = Data.fetchByField("a")
     self.assertEqual(len(keys), 2)
     self.assertTrue(keys[0].get().field == "a")
     self.assertTrue(keys[1].get().field == "a")
     self.assertTrue(keys[0].get().string in ["bb", "x"])
     self.assertTrue(keys[1].get().string in ["bb", "x"])
Exemplo n.º 2
0
 def testSucceeded(self):
     keys = Data.fetchByField("a")
     self.assertEqual(len(keys), 0)
     response = self.testapp.get("/post?a=bb&c=dd&a=x")
     self.assertEqual(json.loads(response.body), [{
         "dataId": 4,
         "field": "a",
         "string": "bb"
     }, {
         "dataId": 5,
         "field": "a",
         "string": "x"
     }, {
         "dataId": 6,
         "field": "c",
         "string": "dd"
     }])
     keys = Data.fetchByField("a")
     self.assertEqual(len(keys), 2)
     self.assertTrue(keys[0].get().field == "a")
     self.assertTrue(keys[1].get().field == "a")
     self.assertTrue(keys[0].get().string in ["bb", "x"])
     self.assertTrue(keys[1].get().string in ["bb", "x"])
Exemplo n.º 3
0
class Field(JsonRpcDispatcher):
    def GET(self, jrequest, jresponse):
        assert isinstance(jrequest, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()
        try:
            field = unicode(jrequest.getPathInfo(3))
        except Exception, e:
            jresponse.setErrorInvalidParameter(e)
            return
        data_keys = Data.fetchByField(field)
        jresponse.setResult([])
        for data_key in data_keys:
            data = data_key.get()
            jresponse.addResult(data)