Skip to content
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

Merged
merged 83 commits into from
Mar 5, 2024

Conversation

Gerwoud
Copy link
Contributor

@Gerwoud Gerwoud commented Feb 25, 2024

Draft pull request for implementation of projects end point

@Gerwoud Gerwoud marked this pull request as ready for review February 26, 2024 18:29
Copy link
Contributor

@AronBuzogany AronBuzogany left a 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.

backend/project/endpoints/projects/project_detail.py Outdated Show resolved Hide resolved
backend/project/endpoints/projects/project_detail.py Outdated Show resolved Hide resolved
backend/project/__main__.py Outdated Show resolved Hide resolved
backend/project/__main__.py Outdated Show resolved Hide resolved
backend/project/endpoints/projects/project_detail.py Outdated Show resolved Hide resolved
backend/tests/endpoints/index_test.py Show resolved Hide resolved
backend/tests/endpoints/project_test.py Show resolved Hide resolved
backend/tests/endpoints/project_test.py Outdated Show resolved Hide resolved
backend/tests/endpoints/project_test.py Show resolved Hide resolved
backend/tests/endpoints/project_test.py Outdated Show resolved Hide resolved
"content": {
"application/json": {
"schema": {
"type": "ojbect",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"ojbect" -> "object"

Copy link
Contributor Author

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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"op" -> "of"

Copy link
Contributor Author

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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"user" -> "project"

Copy link
Contributor Author

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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"ojbect" -> "object"

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"is" -> "in"

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Detele" -> "Delete"

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"route" -> "routes"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"experssions" -> "expressions"

Copy link
Contributor Author

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,
Copy link
Contributor

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

Copy link
Contributor Author

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

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"disalbe" -> "disable"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"intance" -> "instance"

Copy link
Contributor Author

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)
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#32


@pytest.fixture
def course_teacher():
"""A user that's a teacher for for testing"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double for

Copy link
Contributor Author

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,
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#32

"deadline": project.deadline,
"course_id": project.course_id,
"visible_for_students": project.visible_for_students,
"archieved": project.archieved,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the others

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#32



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"""
Copy link
Contributor

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

Copy link
Contributor Author

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"""
Copy link
Contributor

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"""

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gerwoud Gerwoud requested a review from Vucis March 4, 2024 11:38
# 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
@AronBuzogany AronBuzogany merged commit f918b18 into development Mar 5, 2024
4 checks passed
@AronBuzogany AronBuzogany deleted the backend/feature/projects-endpoint branch March 5, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create API endpoint for projects
3 participants