1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 04:54:18 +00:00

completati test PATCH e DELETE conditions

This commit is contained in:
stefanogoldoni 2021-05-15 12:00:49 +02:00
parent bab945fdbd
commit 29ec779203

View file

@ -33,32 +33,54 @@ class TestConditionPost:
def test_wrong_type(self, flask_client: Client, user_headers): def test_wrong_type(self, flask_client: Client, user_headers):
r = flask_client.post(f'/api/v1/repositories/1/conditions', headers=user_headers, r = flask_client.post(f'/api/v1/repositories/1/conditions', headers=user_headers,
json={"content": "string", "type": 99}) json={"content": "string", "type": 99})
assert r.status_code == 400 # ottengo 500 assert r.status_code == 400
assert r.json["result"] == "failure" assert r.json["result"] == "failure"
def test_missing_content(self, flask_client: Client, user_headers): def test_missing_content(self, flask_client: Client, user_headers):
r = flask_client.post(f'/api/v1/repositories/1/conditions', headers=user_headers, r = flask_client.post(f'/api/v1/repositories/1/conditions', headers=user_headers,
json={"type": 0}) json={"type": 0})
assert r.status_code == 400 # ottengo 500 assert r.status_code == 400
assert r.json["result"] == "failure" assert r.json["result"] == "failure"
def test_for_success(self, flask_client: Client, user_headers): def test_for_success(self, flask_client: Client, user_headers):
r = flask_client.post(f'/api/v1/repositories/1/conditions', headers=user_headers, r = flask_client.post(f'/api/v1/repositories/1/conditions', headers=user_headers,
json={"content": "string", "type": 0}) json={"content": "onlyForTest", "type": 0})
assert r.status_code == 201 assert r.status_code == 201
assert r.json["result"] == "success" assert r.json["result"] == "success"
# test del file condition # test del file condition
class TestConditionGetOneOfARepository: class TestOneConditionOfARepository:
def test_condition_not_found(selfself, flask_client: Client, user_headers): def test_condition_not_found(self, flask_client: Client, user_headers):
r = flask_client.get(f'/api/v1/conditions/999', headers=user_headers) r = flask_client.get(f'/api/v1/conditions/99', headers=user_headers)
assert r.status_code == 404 assert r.status_code == 404
assert r.json["result"] == "failure" assert r.json["result"] == "failure"
# TODO: testare GET # test GET
def test_get_condition(self, flask_client: Client, user_headers):
r = flask_client.get(f'/api/v1/conditions/3', headers=user_headers)
assert r.status_code == 200
assert r.json["result"] == "success"
# TODO: testare PATCH # test PATCH
def test_patch_condition_no_json(self, flask_client: Client, user_headers):
r = flask_client.patch(f'/api/v1/conditions/3', headers=user_headers)
assert r.status_code == 400
assert r.json["result"] == "failure"
# TODO: testare DELETE def test_patch_condition_wrong_type(self, flask_client: Client, user_headers):
r = flask_client.patch(f'/api/v1/conditions/3', headers=user_headers,
json={"content": "string", "type": 99})
assert r.status_code == 400
assert r.json["result"] == "failure"
def test_patch_condition_for_success(self, flask_client: Client, user_headers):
r = flask_client.patch(f'/api/v1/conditions/3', headers=user_headers,
json={"content": "patchedForTest", "type": 0})
assert r.status_code == 204
# test DELETE
def test_delete_condition_for_success(self, flask_client: Client, user_headers):
r = flask_client.delete(f'/api/v1/conditions/3', headers=user_headers)
assert r.status_code == 204