def test_http_put(self): fake = Factory.create("en_GB") client = AsyncHTTPClient(self.io_loop) for _ in range(10): data = {"item":{ "email": fake.email(), "firstname": fake.first_name(), "lastname": fake.last_name(), "_password": fake.password() }} client.fetch("{}Person".format(BASE_URL), self.stop, method="PUT", body=dumps(data), headers={"Content-Type": "application/json", "simple-auth-token":"--foo-bar--"}) response = self.wait() result = loads(response.body.decode("utf-8")) if result.get("error"): raise Exception(result["error"]) for _ in range(10): data = {"item":{ "name": fake.name(), "dob": fake.date(), "active": fake.pybool(), "customer_type": "retail" }} client.fetch("{}Customer".format(BASE_URL), self.stop, method="PUT", body=dumps(data), headers={"Content-Type": "application/json", "simple-auth-token":"--foo-bar--"}) response = self.wait() result = loads(response.body.decode("utf-8")) if result.get("error"): raise Exception(result["error"]) data = { "item": { "line1": fake.address(), "town": fake.city(), "postcode": fake.postcode(), "customer_type": "retail" }, "to_add": [ [ "customers", "Customer", result["result"]["id"] ] ] } client.fetch("{}Address".format(BASE_URL), self.stop, method="PUT", body=dumps(data), headers={"Content-Type": "application/json", "simple-auth-token":"--foo-bar--"}) response = self.wait() result = loads(response.body.decode("utf-8"))
def prepare(self): if self.request.headers.get("Content-Type") == "application/json" and \ self.request.body: self.json_args = loads(str(self.request.body,encoding="UTF-8")) else: self.json_args = None
def _handle_fetch(self, response): result = loads(response.body.decode("utf-8")) self.assertDictContainsSubset({"version": 1}, result, "should have been there") self.assertEquals(len(result["model"]),4) self.stop()
def process_result_value(self, value, dialect): if value is not None: value = loads(value) return value
def _read_changed(self): return utils.loads(self._changed) if self._changed else None
def _read_data(self): return utils.loads(self._data) if self._data else None
def _read_attr_ref(self): return utils.loads(self._attr_ref) if self._attr_ref else None