From c19655e0e7a4fb3fcb8cb1f0be8c231e8fab05f4 Mon Sep 17 00:00:00 2001 From: "@uni-chiara" <258727@studenti.unimore.it> Date: Thu, 27 May 2021 11:00:49 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=93=84=20Aggiornato=20log=20attivit?= =?UTF-8?q?=C3=A0=20individuali?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- legacy/doc/log/sprint-3.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/legacy/doc/log/sprint-3.md b/legacy/doc/log/sprint-3.md index b9e7e8b..77821cb 100644 --- a/legacy/doc/log/sprint-3.md +++ b/legacy/doc/log/sprint-3.md @@ -1,13 +1,13 @@ -# Log riunioni collettive dello Sprint 2 +# Log riunioni collettive dello Sprint 3 | Data | Ora | Durata | Attività | |------|-----|--------|----------| | | | | | -Totale generale di tutti i componenti: 12.0h +Totale generale di tutti i componenti: 12.5h -# Log attività individuali dello Sprint 2 +# Log attività individuali dello Sprint 3 @@ -75,8 +75,9 @@ Chiara Calzolari - UI Designer | 24/05 | 2.0h | Traduzione UI | 24/05 | 1.0h | Traduzione UI | 25/05 | 1.0h | Traduzione UI +| 27/05 | 0.5h | Traduzione UI |-------|--------| -|totale| 12.0h | +|totale| 12.5h | From e1024af599a0707e63a86d80d29110a0724ec88c Mon Sep 17 00:00:00 2001 From: Lorenzo Balugani Date: Thu, 27 May 2021 11:27:23 +0200 Subject: [PATCH 2/3] Fix bug that prevented repos to be deleted --- nest_backend/routes/repository/repository.py | 38 ++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/nest_backend/routes/repository/repository.py b/nest_backend/routes/repository/repository.py index a9907b0..e173df0 100644 --- a/nest_backend/routes/repository/repository.py +++ b/nest_backend/routes/repository/repository.py @@ -181,6 +181,44 @@ def page_repository(rid): if repository.owner_id != user.email and not user.isAdmin: return json_error("You are not the owner of this repository.", REPOSITORY_NOT_OWNER), 403 try: + # Deleting Tweets... + tweets = [t.tweet for t in repository.tweets] + for tweet in tweets: + if len(tweet.repositories) < 2: + # Delete Tweets if only attached to this repo + for conn in tweet.repositories: + ext.session.delete(conn) + for conn in tweet.conditions: + ext.session.delete(conn) + ext.session.delete(tweet) + ext.session.commit() + else: + conns = [conn for conn in tweet.repositories if conn.rid == rid] + for conn in conns: + ext.session.delete(conn) + ext.session.commit() + # Deleting authorizations... + for auth in repository.authorizations: + ext.session.delete(auth) + ext.session.commit() + # Deleting conditions... + for condition in repository.conditions: + ext.session.delete(condition) + ext.session.commit() + # Deleting Alerts... + for alert in repository.alerts: + for elem in alert.conditions: + condition = elem.condition + ext.session.delete(elem) + ext.session.commit() + if not condition.repository_id: + ext.session.delete(condition) + ext.session.commit() + for notification in alert.notifications: + ext.session.delete(notification) + ext.session.commit() + ext.session.delete(alert) + ext.session.commit() ext.session.delete(repository) ext.session.commit() except Exception as e: From 3bdd2825a576754c5b69df1b672e61009d227c53 Mon Sep 17 00:00:00 2001 From: Annielated Date: Thu, 27 May 2021 11:28:30 +0200 Subject: [PATCH 3/3] aggiunti test per autorizzazioni, fix typo --- nest_backend/test/test_2_repository.py | 2 +- nest_backend/test/test_5_authorizations.py | 25 ++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/nest_backend/test/test_2_repository.py b/nest_backend/test/test_2_repository.py index 958f0d8..910c6ae 100644 --- a/nest_backend/test/test_2_repository.py +++ b/nest_backend/test/test_2_repository.py @@ -125,7 +125,7 @@ class TestRepositoryGet: assert r.status_code == 200 assert r.json["result"] == "success" - def test_get_non_existing_repository(self, flask_client: Client, admin_headers): + def test_repository_not_found(self, flask_client: Client, admin_headers): r = flask_client.get(f'/api/v1/repositories/99', headers=admin_headers) assert r.status_code == 404 assert r.json["result"] == "failure" diff --git a/nest_backend/test/test_5_authorizations.py b/nest_backend/test/test_5_authorizations.py index 8ac2824..b91ca7f 100644 --- a/nest_backend/test/test_5_authorizations.py +++ b/nest_backend/test/test_5_authorizations.py @@ -9,7 +9,7 @@ class TestAuthozitazionsGet: assert r.status_code == 200 assert r.json["result"] == "success" - def test_get_non_existing_repository(self, flask_client: Client, admin_headers): + def test_repository_not_found(self, flask_client: Client, admin_headers): r = flask_client.get('/api/v1/repositories/99/authorizations/', headers=admin_headers) assert r.status_code == 404 assert r.json["result"] == "failure" @@ -66,7 +66,28 @@ class TestAuthorizationsPut: r = flask_client.put(f'/api/v1/repositories/1/authorizations/') assert r.status_code == 401 - def test_get_non_existing_repository(self, flask_client: Client, admin_headers): + def test_repository_not_found(self, flask_client: Client, admin_headers): r = flask_client.post('/api/v1/repositories/99/authorizations/', headers=admin_headers) assert r.status_code == 404 assert r.json["result"] == "failure" + + +class TestAuthorizationsDelete: + def test_for_success(self, flask_client: Client, user_headers): + r = flask_client.delete(f'/api/v1/repositories/1/authorizations/user_test@nest.com', headers=user_headers) + assert r.status_code == 204 + assert r.json["result"] == "success" + + def test_user_not_logged(self, flask_client: Client): + r = flask_client.delete(f'/api/v1/repositories/1/authorizations/user_test@nest.com') + assert r.status_code == 401 + + def test_wrong_owner(self, flask_client: Client, admin_headers): + r = flask_client.delete(f'/api/v1/repositories/1/authorizations/user_test@nest.com', headers=admin_headers) + assert r.status_code == 403 + assert r.json["result"] == "failure" + + def test_repository_not_found(self, flask_client: Client, admin_headers): + r = flask_client.delete(f'/api/v1/repositories/99/authorizations/user_test@nest.com', headers=admin_headers) + assert r.status_code == 404 + assert r.json["result"] == "failure"