-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backend/feature/projects endpoint #31
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are adding 2 blueprints. You should instead use one blueprint for both /projects
and /projects/{project_id}
. The implementations are in 2 different files, you can place them into 1 bigger file.
"content": { | ||
"application/json": { | ||
"schema": { | ||
"type": "ojbect", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ojbect" -> "object"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
}, | ||
"patch": { | ||
"description": "Patch certain fields op a project", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"op" -> "of"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
}, | ||
"404": { | ||
"description": "Tried to patch a user that is not present", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"user" -> "project"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"content": { | ||
"application/json": { | ||
"schema": { | ||
"type": "ojbect", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ojbect" -> "object"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# get the project that need to be edited | ||
project = Projects.query.filter_by(project_id=project_id).first() | ||
|
||
# check which values are not None is the dict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"is" -> "in"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
def delete(self, project_id): | ||
""" | ||
Detele a project and all of its submissions in cascade |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Detele" -> "Delete"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,23 @@ | |||
""" | |||
Module for providing the blueprint to the api | |||
of both route |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"route" -> "routes"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backend/project/models/projects.py
Outdated
"""This class describes the projects table, | ||
a projects has an id, a title, a description, | ||
an optional assignment file that can contain more explanation of the projects, | ||
an optional deadline, | ||
the course id of the course to which the project belongs, | ||
visible for students variable so a teacher can decide if the students can see it yet, | ||
archieved var so we can implement the archiving functionality, | ||
a test path,script name and regex experssions for automated testing""" | ||
a test path,script name and regex experssions for automated testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"experssions" -> "expressions"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
from sqlalchemy import ARRAY, Boolean, Column, DateTime, ForeignKey, Integer, String, Text | ||
from project import db | ||
|
||
class Projects(db.Model): | ||
@dataclasses.dataclass | ||
class Projects(db.Model): # pylint: disable=too-many-instance-attributes | ||
"""This class describes the projects table, | ||
a projects has an id, a title, a description, | ||
an optional assignment file that can contain more explanation of the projects, | ||
an optional deadline, | ||
the course id of the course to which the project belongs, | ||
visible for students variable so a teacher can decide if the students can see it yet, | ||
archieved var so we can implement the archiving functionality, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's still archieved in the database but maybe change it to archived here already for when we update the db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not part of this pull request and this should be resolved in #32
backend/project/models/projects.py
Outdated
a test path,script name and regex experssions for automated testing""" | ||
a test path,script name and regex experssions for automated testing | ||
|
||
Pylint disalbe too many intance attributes because we can't reduce the amount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"disalbe" -> "disable"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"intance" -> "instance"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deadline: str = Column(DateTime(timezone=True)) | ||
course_id: int = Column(Integer, ForeignKey("courses.course_id"), nullable=False) | ||
visible_for_students: bool = Column(Boolean, nullable=False) | ||
archieved: bool = Column(Boolean, nullable=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the other archieved, but I think the code won't work anymore if you change this one, so maybe place a todo comment for when we change the db so we can remember
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backend/tests/endpoints/conftest.py
Outdated
|
||
@pytest.fixture | ||
def course_teacher(): | ||
"""A user that's a teacher for for testing""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assignment_file="testfile", | ||
deadline=date, | ||
visible_for_students=True, | ||
archieved=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly maybe just wait with all the archieved's and do one big find replace when the db changes, but still maybe place todo's just in case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"deadline": project.deadline, | ||
"course_id": project.course_id, | ||
"visible_for_students": project.visible_for_students, | ||
"archieved": project.archieved, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as the others
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
def test_post_project(db_session, client, course, course_teacher, project_json): | ||
"""Test posting a project to the datab and testing if it's present""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just write database in full
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
def test_remove_project(db_session, client, course, course_teacher, project_json): | ||
"""Test removing a project to the datab and fetching it, testing if its not present anymore""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Test removing a project to the datab and fetching it, testing if its not present anymore""" -> """Test removing a project from the database and fetching it, testing if it's not present anymore"""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
def test_update_project(db_session, client, course, course_teacher, project): | ||
""" | ||
Test functionality of the PUT method for projects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this test the PATCH method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Conflicts: # backend/project/__init__.py # backend/project/__main__.py # backend/project/db_in.py # backend/project/endpoints/index/OpenAPI_Object.json # backend/project/models/projects.py # backend/tests/endpoints/conftest.py # backend/tests/models/conftest.py
Draft pull request for implementation of projects end point