1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 14:34:19 +00:00

Merge branch 'main' of zero.ryg.one:nest/g2-progetto

This commit is contained in:
@uni-chiara 2021-05-29 13:21:47 +02:00
commit 420afbefd3
2 changed files with 24 additions and 11 deletions

View file

@ -130,6 +130,11 @@ class TestRepositoryGet:
assert r.status_code == 404 assert r.status_code == 404
assert r.json["result"] == "failure" assert r.json["result"] == "failure"
def test_wrong_request_type(self, flask_client: Client, admin_headers):
r = flask_client.put(f'/api/v1/repositories/99', headers=admin_headers)
assert r.status_code == 404
assert r.json["result"] == "failure"
def test_user__not_logged(self, flask_client: Client, ): def test_user__not_logged(self, flask_client: Client, ):
r = flask_client.get(f'/api/v1/repositories/1') r = flask_client.get(f'/api/v1/repositories/1')
assert r.status_code == 401 assert r.status_code == 401
@ -168,6 +173,10 @@ class TestRepositoryPatch:
}) })
assert r.status_code == 204 assert r.status_code == 204
def test_error_500(self, flask_client: Client, user_headers):
r = flask_client.patch(f'/api/v99/repositories/1', headers=user_headers)
assert r.status_code == 500
class TestRepositoryDelete: class TestRepositoryDelete:
def test_wrong_owner(self, flask_client: Client, user_headers): def test_wrong_owner(self, flask_client: Client, user_headers):
@ -198,8 +207,7 @@ class TestRepositoryPut:
assert r.status_code == 401 assert r.status_code == 401
def test_bad_request(self, flask_client: Client, user_headers): def test_bad_request(self, flask_client: Client, user_headers):
r = flask_client.put(f'/api/v1/repositories/1', headers=user_headers, r = flask_client.put(f'/api/v1/repositories/1', headers=user_headers, json={
json={
"name": "string", "name": "string",
"close": "string", "close": "string",
"open": "string", "open": "string",
@ -236,3 +244,7 @@ class TestRepositoryPut:
"start": "2021-05-14T12:12:29.827Z" "start": "2021-05-14T12:12:29.827Z"
}) })
assert r.status_code == 200 assert r.status_code == 200
def test_error_500(self, flask_client: Client, user_headers):
r = flask_client.put(f'/api/v99/repositories/1', headers=user_headers)
assert r.status_code == 500

View file

@ -157,12 +157,7 @@ class TestAlertPost:
assert r.json["result"] == "success" assert r.json["result"] == "success"
class TestAlertGet:
# test del file alert
class TestOneAlertOfARepository:
def test_alert_not_found(self, flask_client: Client, user_headers): def test_alert_not_found(self, flask_client: Client, user_headers):
r = flask_client.get(f'/api/v1/alert/99', headers=user_headers) r = flask_client.get(f'/api/v1/alert/99', headers=user_headers)
assert r.status_code == 404 assert r.status_code == 404
@ -174,7 +169,7 @@ class TestOneAlertOfARepository:
assert r.status_code == 200 assert r.status_code == 200
assert r.json["result"] == "success" assert r.json["result"] == "success"
# test PATCH
def test_patch_alert_no_json(self, flask_client: Client, user_headers): def test_patch_alert_no_json(self, flask_client: Client, user_headers):
r = flask_client.patch(f'/api/v1/alert/1', headers=user_headers) r = flask_client.patch(f'/api/v1/alert/1', headers=user_headers)
assert r.status_code == 400 assert r.status_code == 400
@ -197,7 +192,8 @@ class TestOneAlertOfARepository:
assert r.status_code == 200 assert r.status_code == 200
assert r.json["result"] == "success" assert r.json["result"] == "success"
# test PUT
class TestAlertPut:
def test_put_alert_no_json(self, flask_client: Client, user_headers): def test_put_alert_no_json(self, flask_client: Client, user_headers):
r = flask_client.put(f'/api/v1/alert/2', headers=user_headers) r = flask_client.put(f'/api/v1/alert/2', headers=user_headers)
assert r.status_code == 400 assert r.status_code == 400
@ -309,7 +305,12 @@ class TestOneAlertOfARepository:
assert r.status_code == 400 assert r.status_code == 400
assert r.json["result"] == "failure" assert r.json["result"] == "failure"
# test DELETE
class TestAlertDelete:
def test_delete_alert_for_success(self, flask_client: Client, user_headers): def test_delete_alert_for_success(self, flask_client: Client, user_headers):
r = flask_client.delete(f'/api/v1/alert/1', headers=user_headers) r = flask_client.delete(f'/api/v1/alert/1', headers=user_headers)
assert r.status_code == 204 assert r.status_code == 204
def test_error_500(self, flask_client: Client, user_headers):
r = flask_client.delete(f'/api/v99/alert/1', headers=user_headers)
assert r.status_code == 500