def test_put(): foo = json.loads(next(iter(get(Foo, limit=1)))) bar = foo['bar'] assert bar != 'bang' foo['bar'] = 'bang' updated = put(Foo, foo_id=foo['id'], foo=foo) updated = json.loads(updated) assert updated['bar'] == 'bang' assert updated['id'] == foo['id']
def test_put_returns_400_with_bad_input_data(): foo = json.loads(next(iter(get(Foo, limit=1)))) foo['bar'] = {} _, code = put(Foo, foo_id=foo['id'], foo=foo) assert code == 400
def test_put_fails_with_no_data_key_found(): with pytest.raises(TypeError): put(Foo, foo_id=None)
def test_put_fails_with_invalid_id_key(): with pytest.raises(TypeError): put(Foo, foo={})
def test_put_returns_404_with_invalid_id(): _, code = put(Foo, foo_id=str(uuid.uuid4()), foo={}) assert code == 404