From a33d8d63f11045c56292651766bbc9182f4fbc1b Mon Sep 17 00:00:00 2001 From: stanislawK Date: Sat, 31 Aug 2019 14:38:43 +0200 Subject: [PATCH 1/9] Add participants to hacknight endpoint with tests --- backend/app.py | 3 +- backend/resources/hacknight.py | 37 ++++++++- backend/serializers/participant_serializer.py | 7 ++ backend/tests/test_hacknight.py | 80 +++++++++++++++++++ 4 files changed, 125 insertions(+), 2 deletions(-) diff --git a/backend/app.py b/backend/app.py index 37f3ddc2..d9f41e0d 100644 --- a/backend/app.py +++ b/backend/app.py @@ -5,7 +5,7 @@ from backend.extensions import api, db, mail, migrate, jwt from backend.resources.auth import UserLogin, UserLogout from backend.resources.contact import SendMessage -from backend.resources.hacknight import HacknightList +from backend.resources.hacknight import HacknightDetails, HacknightList from backend.resources.participant import ParticipantDetails, ParticipantsList @@ -40,3 +40,4 @@ def initialize_extensions(app): api.add_resource(ParticipantsList, "/participants/") api.add_resource(ParticipantDetails, "/participants//") api.add_resource(HacknightList, "/hacknights/") +api.add_resource(HacknightDetails, "/hacknights//") diff --git a/backend/resources/hacknight.py b/backend/resources/hacknight.py index b82ab68c..b988e61a 100644 --- a/backend/resources/hacknight.py +++ b/backend/resources/hacknight.py @@ -8,8 +8,9 @@ from marshmallow import ValidationError from backend.extensions import db -from backend.models import Hacknight +from backend.models import Hacknight, Participant from backend.serializers.hacknight_serializer import HacknightSchema +from backend.serializers.participant_serializer import ParticipantIdSchema class HacknightList(Resource): @@ -44,3 +45,37 @@ def post(self): return {'message': 'Hacknight created successfully.', "hacknight": data}, HTTPStatus.CREATED + + +class HacknightDetails(Resource): + @jwt_required + def patch(self, id): + hacknight = Hacknight.query.get_or_404(id) + participants = [ + participant.id for participant in hacknight.participants + ] + + json_data = request.get_json(force=True) + ids_schema = ParticipantIdSchema() + try: + data = ids_schema.load(json_data) + except ValidationError as err: + return (err.messages), HTTPStatus.BAD_REQUEST + + new_participants = [ + id for id in data['participants'] if id not in participants + ] + + if not new_participants: + return {'message': 'No new participant has been provided'}, \ + HTTPStatus.BAD_REQUEST + + for new_particpiant in new_participants: + hacknight.participants.append( + Participant.query.get_or_404(new_particpiant) + ) + db.session.commit() + + hacknight_schema = HacknightSchema() + return {"hacknight": hacknight_schema.dump(hacknight)}, \ + HTTPStatus.OK diff --git a/backend/serializers/participant_serializer.py b/backend/serializers/participant_serializer.py index f7ca26a5..fea93bef 100644 --- a/backend/serializers/participant_serializer.py +++ b/backend/serializers/participant_serializer.py @@ -18,3 +18,10 @@ class Meta: many=True ) phone = fields.Str(validate=[validate.Length(max=13)]) + + +class ParticipantIdSchema(Schema): + class Meta: + fields = ('participants', ) + + participants = fields.List(fields.Int(), required=True) diff --git a/backend/tests/test_hacknight.py b/backend/tests/test_hacknight.py index 1b650aa9..98273585 100644 --- a/backend/tests/test_hacknight.py +++ b/backend/tests/test_hacknight.py @@ -1,4 +1,7 @@ from http import HTTPStatus +import json + +from backend.models import Hacknight, Participant def test_get_hacknights_when_logged_in( @@ -31,3 +34,80 @@ def test_get_hacknights_unauthorized(client, add_hacknights): response = rv.get_json() assert rv.status_code == HTTPStatus.UNAUTHORIZED assert response['msg'] == 'Missing Authorization Header' + + +def test_add_participants_to_hacknight( + access_token, add_hacknights, add_participants, client +): + """Test add new participant to hacknight.""" + payload = {'participants': [1, 3]} + rv = client.patch( + '/hacknights/1/', + headers={'Authorization': 'Bearer {}'.format(access_token)}, + data=json.dumps(payload) + ) + resp = rv.get_json() + participants_ids = [ + participant['id'] for participant in resp['hacknight']['participants'] + ] + assert rv.status_code == HTTPStatus.OK + for participant in resp['hacknight']['participants']: + assert participant['id'] in payload['participants'] + + +def test_add_participants_to_hacknight_unauthorized( + add_hacknights, add_participants, client +): + """Test add participants to hacknight when user is not logged in.""" + payload = {'participants': [1, 3]} + rv = client.patch('/hacknights/1/', data=json.dumps(payload)) + response = rv.get_json() + assert rv.status_code == HTTPStatus.UNAUTHORIZED + assert response['msg'] == 'Missing Authorization Header' + + +def test_add_nonexistent_participants_to_hacknight( + access_token, add_hacknights, client +): + """Test add non-existent participants ids to hacknight.""" + payload = {'participants': [1, 3]} + rv = client.patch( + '/hacknights/1/', + headers={'Authorization': 'Bearer {}'.format(access_token)}, + data=json.dumps(payload) + ) + response = rv.get_json() + assert rv.status_code == HTTPStatus.NOT_FOUND + + +def test_add_participants_to_nonexistent_hacknight( + access_token, add_participants, client +): + """Test add participants to non-existent hacknight.""" + payload = {'participants': [1, 3]} + rv = client.patch( + '/hacknights/1/', + headers={'Authorization': 'Bearer {}'.format(access_token)}, + data=json.dumps(payload) + ) + response = rv.get_json() + assert rv.status_code == HTTPStatus.NOT_FOUND + + +def test_duplicate_participant_in_hacknight( + access_token, add_hacknights, add_participants, client, _db +): + """Test add participant who is in hacknight already.""" + hacknight = _db.session.query(Hacknight).first() + participant = _db.session.query(Participant).first() + hacknight.participants.append(participant) + + payload = {'participants': [participant.id]} + rv = client.patch( + '/hacknights/{}/'.format(hacknight.id), + headers={'Authorization': 'Bearer {}'.format(access_token)}, + data=json.dumps(payload) + ) + response = rv.get_json() + assert rv.status_code == HTTPStatus.BAD_REQUEST + assert response['message'] == 'No new participant has been provided' From c26beab8aab80639468213f6a651525790f4381b Mon Sep 17 00:00:00 2001 From: stanislawK Date: Wed, 18 Sep 2019 19:02:12 +0200 Subject: [PATCH 2/9] Fixed typos in hacknight's resource and tests --- backend/resources/hacknight.py | 4 ++-- backend/tests/test_hacknight.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/resources/hacknight.py b/backend/resources/hacknight.py index b988e61a..6287babe 100644 --- a/backend/resources/hacknight.py +++ b/backend/resources/hacknight.py @@ -70,9 +70,9 @@ def patch(self, id): return {'message': 'No new participant has been provided'}, \ HTTPStatus.BAD_REQUEST - for new_particpiant in new_participants: + for new_participant in new_participants: hacknight.participants.append( - Participant.query.get_or_404(new_particpiant) + Participant.query.get_or_404(new_participant) ) db.session.commit() diff --git a/backend/tests/test_hacknight.py b/backend/tests/test_hacknight.py index 98273585..70043bd0 100644 --- a/backend/tests/test_hacknight.py +++ b/backend/tests/test_hacknight.py @@ -66,10 +66,10 @@ def test_add_participants_to_hacknight_unauthorized( assert response['msg'] == 'Missing Authorization Header' -def test_add_nonexistent_participants_to_hacknight( +def test_add_nonexisting_participants_to_hacknight( access_token, add_hacknights, client ): - """Test add non-existent participants ids to hacknight.""" + """Test add non-existing participants ids to hacknight.""" payload = {'participants': [1, 3]} rv = client.patch( '/hacknights/1/', @@ -80,7 +80,7 @@ def test_add_nonexistent_participants_to_hacknight( assert rv.status_code == HTTPStatus.NOT_FOUND -def test_add_participants_to_nonexistent_hacknight( +def test_add_participants_to_non_existing_hacknight( access_token, add_participants, client ): """Test add participants to non-existent hacknight.""" @@ -97,7 +97,7 @@ def test_add_participants_to_nonexistent_hacknight( def test_duplicate_participant_in_hacknight( access_token, add_hacknights, add_participants, client, _db ): - """Test add participant who is in hacknight already.""" + """Test add participant who is already in hacknight..""" hacknight = _db.session.query(Hacknight).first() participant = _db.session.query(Participant).first() hacknight.participants.append(participant) From 19653772777fff50a7af0b260ebe2822ea8dcd9c Mon Sep 17 00:00:00 2001 From: stanislawK Date: Wed, 18 Sep 2019 19:15:02 +0200 Subject: [PATCH 3/9] fixed js lint errors --- frontend/src/components/Dashboard.vue | 12 +++--------- frontend/src/router.js | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/Dashboard.vue b/frontend/src/components/Dashboard.vue index e3568784..398e6a93 100644 --- a/frontend/src/components/Dashboard.vue +++ b/frontend/src/components/Dashboard.vue @@ -1,15 +1,9 @@ - - - + diff --git a/frontend/src/router.js b/frontend/src/router.js index 8311928b..03ebdc7b 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -10,7 +10,7 @@ Vue.use(VueRouter); const routes = [ { path: '/', component: HomePage }, { path: '/login', component: Login }, - { path: '/dashboard', component: Dashboard} + { path: '/dashboard', component: Dashboard } ]; export default new VueRouter({ mode: 'history', routes }); From 7b38ef638ed0c4bf040cf71ab1af11ba0d90a184 Mon Sep 17 00:00:00 2001 From: stanislawK Date: Wed, 2 Oct 2019 19:57:44 +0200 Subject: [PATCH 4/9] Added participants_ids field to ParticipanSchema --- backend/resources/hacknight.py | 7 ++++--- backend/serializers/participant_serializer.py | 4 +++- backend/tests/test_hacknight.py | 20 +++++++++++-------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/backend/resources/hacknight.py b/backend/resources/hacknight.py index 6287babe..9a1c30ff 100644 --- a/backend/resources/hacknight.py +++ b/backend/resources/hacknight.py @@ -10,7 +10,7 @@ from backend.extensions import db from backend.models import Hacknight, Participant from backend.serializers.hacknight_serializer import HacknightSchema -from backend.serializers.participant_serializer import ParticipantIdSchema +from backend.serializers.participant_serializer import ParticipantSchema class HacknightList(Resource): @@ -56,14 +56,14 @@ def patch(self, id): ] json_data = request.get_json(force=True) - ids_schema = ParticipantIdSchema() + ids_schema = ParticipantSchema(only=('participants_ids',)) try: data = ids_schema.load(json_data) except ValidationError as err: return (err.messages), HTTPStatus.BAD_REQUEST new_participants = [ - id for id in data['participants'] if id not in participants + id for id in data['participants_ids'] if id not in participants ] if not new_participants: @@ -74,6 +74,7 @@ def patch(self, id): hacknight.participants.append( Participant.query.get_or_404(new_participant) ) + db.session.add(hacknight) db.session.commit() hacknight_schema = HacknightSchema() diff --git a/backend/serializers/participant_serializer.py b/backend/serializers/participant_serializer.py index fea93bef..e4bc9d26 100644 --- a/backend/serializers/participant_serializer.py +++ b/backend/serializers/participant_serializer.py @@ -4,10 +4,12 @@ class ParticipantSchema(Schema): class Meta: fields = ( - 'id', 'name', 'lastname', 'email', 'github', 'hacknights', 'phone' + 'id', 'participants_ids', 'name', 'lastname', + 'email', 'github', 'hacknights', 'phone' ) dump_only = ('id', 'hacknights') + participants_ids = fields.List(fields.Int()) name = fields.Str(required=True, validate=[validate.Length(max=50)]) lastname = fields.Str(validate=[validate.Length(max=50)]) email = fields.Email(validate=[validate.Length(max=200)]) diff --git a/backend/tests/test_hacknight.py b/backend/tests/test_hacknight.py index 70043bd0..27f2976a 100644 --- a/backend/tests/test_hacknight.py +++ b/backend/tests/test_hacknight.py @@ -40,7 +40,7 @@ def test_add_participants_to_hacknight( access_token, add_hacknights, add_participants, client ): """Test add new participant to hacknight.""" - payload = {'participants': [1, 3]} + payload = {'participants_ids': [1, 3]} rv = client.patch( '/hacknights/1/', headers={'Authorization': 'Bearer {}'.format(access_token)}, @@ -51,15 +51,19 @@ def test_add_participants_to_hacknight( participant['id'] for participant in resp['hacknight']['participants'] ] assert rv.status_code == HTTPStatus.OK + + hacknight_db = Hacknight.query.get(1) + ids_from_db = [part.id for part in hacknight_db.participants] for participant in resp['hacknight']['participants']: - assert participant['id'] in payload['participants'] + assert participant['id'] in payload['participants_ids'] + assert ids_from_db == payload['participants_ids'] def test_add_participants_to_hacknight_unauthorized( add_hacknights, add_participants, client ): """Test add participants to hacknight when user is not logged in.""" - payload = {'participants': [1, 3]} + payload = {'participants_ids': [1, 3]} rv = client.patch('/hacknights/1/', data=json.dumps(payload)) response = rv.get_json() assert rv.status_code == HTTPStatus.UNAUTHORIZED @@ -70,7 +74,7 @@ def test_add_nonexisting_participants_to_hacknight( access_token, add_hacknights, client ): """Test add non-existing participants ids to hacknight.""" - payload = {'participants': [1, 3]} + payload = {'participants_ids': [1, 3]} rv = client.patch( '/hacknights/1/', headers={'Authorization': 'Bearer {}'.format(access_token)}, @@ -80,11 +84,11 @@ def test_add_nonexisting_participants_to_hacknight( assert rv.status_code == HTTPStatus.NOT_FOUND -def test_add_participants_to_non_existing_hacknight( +def test_add_participants_to_nonexisting_hacknight( access_token, add_participants, client ): - """Test add participants to non-existent hacknight.""" - payload = {'participants': [1, 3]} + """Test add participants to non-existing hacknight.""" + payload = {'participants_ids': [1, 3]} rv = client.patch( '/hacknights/1/', headers={'Authorization': 'Bearer {}'.format(access_token)}, @@ -102,7 +106,7 @@ def test_duplicate_participant_in_hacknight( participant = _db.session.query(Participant).first() hacknight.participants.append(participant) - payload = {'participants': [participant.id]} + payload = {'participants_ids': [participant.id]} rv = client.patch( '/hacknights/{}/'.format(hacknight.id), headers={'Authorization': 'Bearer {}'.format(access_token)}, From 4cbb743064c62ee07081a6c3993b77024417f1e6 Mon Sep 17 00:00:00 2001 From: stanislawK Date: Wed, 9 Oct 2019 18:52:39 +0200 Subject: [PATCH 5/9] Deleted ParticipanIDSchema --- backend/serializers/participant_serializer.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/backend/serializers/participant_serializer.py b/backend/serializers/participant_serializer.py index e4bc9d26..f8b56e5a 100644 --- a/backend/serializers/participant_serializer.py +++ b/backend/serializers/participant_serializer.py @@ -20,10 +20,3 @@ class Meta: many=True ) phone = fields.Str(validate=[validate.Length(max=13)]) - - -class ParticipantIdSchema(Schema): - class Meta: - fields = ('participants', ) - - participants = fields.List(fields.Int(), required=True) From f9cfbd270b7dbe2ebb426e51a2b9aa7bac1a4251 Mon Sep 17 00:00:00 2001 From: stanislawK Date: Wed, 6 Nov 2019 20:06:31 +0100 Subject: [PATCH 6/9] Fixes in test_hacknight --- backend/tests/test_hacknight.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/backend/tests/test_hacknight.py b/backend/tests/test_hacknight.py index 27f2976a..99b99abb 100644 --- a/backend/tests/test_hacknight.py +++ b/backend/tests/test_hacknight.py @@ -47,13 +47,10 @@ def test_add_participants_to_hacknight( data=json.dumps(payload) ) resp = rv.get_json() - participants_ids = [ - participant['id'] for participant in resp['hacknight']['participants'] - ] assert rv.status_code == HTTPStatus.OK hacknight_db = Hacknight.query.get(1) - ids_from_db = [part.id for part in hacknight_db.participants] + ids_from_db = [participant.id for participant in hacknight_db.participants] for participant in resp['hacknight']['participants']: assert participant['id'] in payload['participants_ids'] assert ids_from_db == payload['participants_ids'] @@ -80,7 +77,6 @@ def test_add_nonexisting_participants_to_hacknight( headers={'Authorization': 'Bearer {}'.format(access_token)}, data=json.dumps(payload) ) - response = rv.get_json() assert rv.status_code == HTTPStatus.NOT_FOUND @@ -94,14 +90,13 @@ def test_add_participants_to_nonexisting_hacknight( headers={'Authorization': 'Bearer {}'.format(access_token)}, data=json.dumps(payload) ) - response = rv.get_json() assert rv.status_code == HTTPStatus.NOT_FOUND def test_duplicate_participant_in_hacknight( access_token, add_hacknights, add_participants, client, _db ): - """Test add participant who is already in hacknight..""" + """Test add participant who is already in hacknight.""" hacknight = _db.session.query(Hacknight).first() participant = _db.session.query(Participant).first() hacknight.participants.append(participant) From b983255bec5b1aa08f0a335903a9aa0010f4102c Mon Sep 17 00:00:00 2001 From: stanislawK Date: Sat, 9 Nov 2019 15:43:12 +0100 Subject: [PATCH 7/9] Removed participants_ids field in ParticipantSchema --- backend/requirements.txt | 2 +- backend/resources/hacknight.py | 9 +++++---- backend/serializers/participant_serializer.py | 5 ++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/requirements.txt b/backend/requirements.txt index 865480c6..26230628 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -3,7 +3,7 @@ Flask-SQLAlchemy==2.4.0 Flask-Migrate==2.3.0 psycopg2==2.8.3 pytest==5.0.1 -marshmallow==3.0.0rc1 +marshmallow==3.2.2 flask-jwt-extended==3.14.0 flask-cors==3.0.7 Flask-Mail==0.9.1 diff --git a/backend/resources/hacknight.py b/backend/resources/hacknight.py index fc18dc7a..2b2727dd 100644 --- a/backend/resources/hacknight.py +++ b/backend/resources/hacknight.py @@ -5,12 +5,11 @@ from flask_jwt_extended import jwt_required from flask_restful import Resource -from marshmallow import ValidationError +from marshmallow import fields, Schema, ValidationError from backend.extensions import db from backend.models import Hacknight, Participant from backend.serializers.hacknight_serializer import HacknightSchema -from backend.serializers.participant_serializer import ParticipantSchema class HacknightList(Resource): @@ -64,9 +63,11 @@ def patch(self, id): ] json_data = request.get_json(force=True) - ids_schema = ParticipantSchema(only=('participants_ids',)) + ids_schema = Schema.from_dict( + {"participants_ids": fields.List(fields.Int())} + ) try: - data = ids_schema.load(json_data) + data = ids_schema().load(json_data) except ValidationError as err: return (err.messages), HTTPStatus.BAD_REQUEST diff --git a/backend/serializers/participant_serializer.py b/backend/serializers/participant_serializer.py index f8b56e5a..bd575b2a 100644 --- a/backend/serializers/participant_serializer.py +++ b/backend/serializers/participant_serializer.py @@ -4,12 +4,11 @@ class ParticipantSchema(Schema): class Meta: fields = ( - 'id', 'participants_ids', 'name', 'lastname', - 'email', 'github', 'hacknights', 'phone' + 'id', 'name', 'lastname', 'email', + 'github', 'hacknights', 'phone' ) dump_only = ('id', 'hacknights') - participants_ids = fields.List(fields.Int()) name = fields.Str(required=True, validate=[validate.Length(max=50)]) lastname = fields.Str(validate=[validate.Length(max=50)]) email = fields.Email(validate=[validate.Length(max=200)]) From cd311cfc3c6fedf581d81de696a0a2867edf1919 Mon Sep 17 00:00:00 2001 From: stanislawK Date: Wed, 20 Nov 2019 18:57:11 +0100 Subject: [PATCH 8/9] Pulled changes in participant serializer from master --- backend/resources/participant.py | 1 - backend/serializers/participant_serializer.py | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/backend/resources/participant.py b/backend/resources/participant.py index 8e9edf11..8ba29918 100644 --- a/backend/resources/participant.py +++ b/backend/resources/participant.py @@ -55,4 +55,3 @@ def delete(self, id): db.session.commit() return {"message": "Participant deleted successfully."}, HTTPStatus.OK - \ No newline at end of file diff --git a/backend/serializers/participant_serializer.py b/backend/serializers/participant_serializer.py index 494a56aa..32039b94 100644 --- a/backend/serializers/participant_serializer.py +++ b/backend/serializers/participant_serializer.py @@ -3,10 +3,8 @@ class ParticipantSchema(Schema): class Meta: - fields = ( - 'id', 'name', 'lastname', 'email', - 'github', 'hacknights', 'phone' - ) + fields = ('id', 'first_name', 'last_name', 'email', 'github', 'hacknights', 'phone') + dump_only = ('id', 'hacknights') first_name = fields.Str(required=True, validate=[validate.Length(max=50)]) From 7030011fa7d027b5863037c556989c975435eb59 Mon Sep 17 00:00:00 2001 From: stanislawK Date: Wed, 11 Dec 2019 19:55:50 +0100 Subject: [PATCH 9/9] Changed resource path --- backend/app.py | 7 ++++++- backend/resources/hacknight.py | 4 +++- backend/tests/test_hacknight.py | 18 +++++++++--------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/backend/app.py b/backend/app.py index 2197897e..6b3dcde4 100644 --- a/backend/app.py +++ b/backend/app.py @@ -10,7 +10,11 @@ RevokeRefreshToken, ) from backend.resources.contact import SendMessage -from backend.resources.hacknight import HacknightDetails, HacknightList +from backend.resources.hacknight import ( + HacknightDetails, + HacknightList, + HacknightParticipants, +) from backend.resources.participant import ParticipantDetails, ParticipantsList @@ -37,6 +41,7 @@ def initialize_extensions(app): api.add_resource(HacknightList, "/hacknights/") api.add_resource(HacknightDetails, "/hacknights//") +api.add_resource(HacknightParticipants, "/hacknights//participants/") api.add_resource(ParticipantDetails, "/participants//") api.add_resource(ParticipantsList, "/participants/") api.add_resource(RefreshAccessToken, "/auth/refresh/") diff --git a/backend/resources/hacknight.py b/backend/resources/hacknight.py index e451aabd..81684f51 100644 --- a/backend/resources/hacknight.py +++ b/backend/resources/hacknight.py @@ -55,8 +55,10 @@ def get(self, id): HTTPStatus.OK, ) + +class HacknightParticipants(Resource): @jwt_required - def patch(self, id): + def post(self, id): hacknight = Hacknight.query.get_or_404(id) participants = [participant.id for participant in hacknight.participants] diff --git a/backend/tests/test_hacknight.py b/backend/tests/test_hacknight.py index c60df831..c48c44d2 100644 --- a/backend/tests/test_hacknight.py +++ b/backend/tests/test_hacknight.py @@ -37,8 +37,8 @@ def test_add_participants_to_hacknight( ): """Test add new participant to hacknight.""" payload = {"participants_ids": [1, 3]} - rv = client.patch( - "/hacknights/1/", + rv = client.post( + "/hacknights/1/participants/", headers={"Authorization": "Bearer {}".format(access_token)}, data=json.dumps(payload), ) @@ -57,7 +57,7 @@ def test_add_participants_to_hacknight_unauthorized( ): """Test add participants to hacknight when user is not logged in.""" payload = {"participants_ids": [1, 3]} - rv = client.patch("/hacknights/1/", data=json.dumps(payload)) + rv = client.post("/hacknights/1/participants/", data=json.dumps(payload)) response = rv.get_json() assert rv.status_code == HTTPStatus.UNAUTHORIZED assert response["msg"] == "Missing Authorization Header" @@ -68,8 +68,8 @@ def test_add_nonexisting_participants_to_hacknight( ): """Test add non-existing participants ids to hacknight.""" payload = {"participants_ids": [1, 3]} - rv = client.patch( - "/hacknights/1/", + rv = client.post( + "/hacknights/1/participants/", headers={"Authorization": "Bearer {}".format(access_token)}, data=json.dumps(payload), ) @@ -81,8 +81,8 @@ def test_add_participants_to_nonexisting_hacknight( ): """Test add participants to non-existing hacknight.""" payload = {"participants_ids": [1, 3]} - rv = client.patch( - "/hacknights/1/", + rv = client.post( + "/hacknights/1/participants/", headers={"Authorization": "Bearer {}".format(access_token)}, data=json.dumps(payload), ) @@ -98,8 +98,8 @@ def test_duplicate_participant_in_hacknight( hacknight.participants.append(participant) payload = {"participants_ids": [participant.id]} - rv = client.patch( - "/hacknights/{}/".format(hacknight.id), + rv = client.post( + "/hacknights/{}/participants/".format(hacknight.id), headers={"Authorization": "Bearer {}".format(access_token)}, data=json.dumps(payload), )