From 3f3f1066caa28e6530f2eda625e5f01caff3d04e Mon Sep 17 00:00:00 2001 From: Annielated Date: Fri, 28 May 2021 19:01:55 +0200 Subject: [PATCH] aggiunti test sui tweet --- nest_backend/test/test_6_tweet.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 nest_backend/test/test_6_tweet.py diff --git a/nest_backend/test/test_6_tweet.py b/nest_backend/test/test_6_tweet.py new file mode 100644 index 0000000..a8f822d --- /dev/null +++ b/nest_backend/test/test_6_tweet.py @@ -0,0 +1,25 @@ +from flask.testing import Client + +'''A file that contains tests classes and methods for all the requests concerning Tweets.''' +# TODO capire come passare i Tweet nell'URL + + +class TestTweetGet: + def test_for_success(self, flask_client: Client, user_headers): + r = flask_client.get(f'/api/v1/repositories/1/tweets/', headers=user_headers) + assert r.status_code == 200 + assert r.json["result"] == "success" + + def test_repository_not_found(self, flask_client: Client, user_headers): + r = flask_client.get(f'/api/v1/repositories/99/tweets/', headers=user_headers) + assert r.status_code == 404 + assert r.json["result"] == "failure" + + def test_user_wrong_owner(self, flask_client: Client, user_headers): + r = flask_client.get(f'/api/v1/repositories/2/tweets/', headers=user_headers) + assert r.status_code == 403 + assert r.json["result"] == "failure" + + def test_user_not_logged(self, flask_client: Client, ): + r = flask_client.get(f'/api/v1/repositories/2/tweets/') + assert r.status_code == 401