def test_thing_get_by_name(client): thing = ThingFactory(name="something") res = client.get("/thing/get_by_name?name=something") assert res.status_code == 200 assert res.get_json()["data"]["id"] == thing.id assert res.get_json()["data"]["attributes"]["name"] == thing.name
def test_thing_get_by_name(client): thing = ThingFactory(name="something") q_params = {"name": "something"} res = client.get("/thing/get_by_name", query_string=q_params) assert res.status_code == 200 assert res.get_json()["data"]["id"] == thing.id assert res.get_json()["data"]["attributes"]["name"] == thing.name
def test_thing_get_fields(client): """ Test that only the specified fields are returned """ thing = ThingFactory(name="something", description="nothing") q_params = {"fields[thing]" : "name"} res = client.get(f"/thing/{thing.id}", query_string=q_params) assert res.status_code == 200 assert res.get_json()["data"]["id"] == thing.id assert res.get_json()["data"]["attributes"]["name"] == thing.name assert res.get_json()["data"]["attributes"].get("description") is None
def test_invalid_jsonapirpc(client): thing = ThingFactory(name="something", description="nothing") res = client.get("/thing/get_by_name") assert res.status_code == 500