From 37392b576fca14ceb69e85cfa4d08a410362d9a7 Mon Sep 17 00:00:00 2001 From: Annielated Date: Sat, 29 May 2021 13:03:13 +0200 Subject: [PATCH] piccoli fix alla struttura dei test --- nest_backend/test/test_2_repository.py | 16 ++++++++++++++-- nest_backend/test/test_4_alert.py | 19 ++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/nest_backend/test/test_2_repository.py b/nest_backend/test/test_2_repository.py index 9c393b7..79eef1a 100644 --- a/nest_backend/test/test_2_repository.py +++ b/nest_backend/test/test_2_repository.py @@ -130,6 +130,11 @@ class TestRepositoryGet: assert r.status_code == 404 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, ): r = flask_client.get(f'/api/v1/repositories/1') assert r.status_code == 401 @@ -168,6 +173,10 @@ class TestRepositoryPatch: }) 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: def test_wrong_owner(self, flask_client: Client, user_headers): @@ -198,8 +207,7 @@ class TestRepositoryPut: assert r.status_code == 401 def test_bad_request(self, flask_client: Client, user_headers): - r = flask_client.put(f'/api/v1/repositories/1', headers=user_headers, - json={ + r = flask_client.put(f'/api/v1/repositories/1', headers=user_headers, json={ "name": "string", "close": "string", "open": "string", @@ -236,3 +244,7 @@ class TestRepositoryPut: "start": "2021-05-14T12:12:29.827Z" }) 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 diff --git a/nest_backend/test/test_4_alert.py b/nest_backend/test/test_4_alert.py index 0e393d3..f0cd0fb 100644 --- a/nest_backend/test/test_4_alert.py +++ b/nest_backend/test/test_4_alert.py @@ -157,12 +157,7 @@ class TestAlertPost: assert r.json["result"] == "success" - - - # test del file alert - - -class TestOneAlertOfARepository: +class TestAlertGet: def test_alert_not_found(self, flask_client: Client, user_headers): r = flask_client.get(f'/api/v1/alert/99', headers=user_headers) assert r.status_code == 404 @@ -174,7 +169,7 @@ class TestOneAlertOfARepository: assert r.status_code == 200 assert r.json["result"] == "success" - # test PATCH + def test_patch_alert_no_json(self, flask_client: Client, user_headers): r = flask_client.patch(f'/api/v1/alert/1', headers=user_headers) assert r.status_code == 400 @@ -197,7 +192,8 @@ class TestOneAlertOfARepository: assert r.status_code == 200 assert r.json["result"] == "success" - # test PUT + +class TestAlertPut: def test_put_alert_no_json(self, flask_client: Client, user_headers): r = flask_client.put(f'/api/v1/alert/2', headers=user_headers) assert r.status_code == 400 @@ -309,7 +305,12 @@ class TestOneAlertOfARepository: assert r.status_code == 400 assert r.json["result"] == "failure" - # test DELETE + +class TestAlertDelete: def test_delete_alert_for_success(self, flask_client: Client, user_headers): r = flask_client.delete(f'/api/v1/alert/1', headers=user_headers) 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