diff --git a/README.md b/README.md index c7522f41b..5641c4ea5 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,8 @@ Described [here](./Application.md) ### Your tasks 1. Add missing APIs mentioned [here](./Application.md#Missing-APIs) and get the automated tests to pass 2. Add a test for grading API -3. Get the test coverage to 94% or above +3. All tests should pass +4. Get the test coverage to 94% or above ## Submission diff --git a/core/models/assignments.py b/core/models/assignments.py index 783222bb0..1253cb85d 100644 --- a/core/models/assignments.py +++ b/core/models/assignments.py @@ -64,8 +64,6 @@ def submit(cls, _id, teacher_id, principal: Principal): assignment = Assignment.get_by_id(_id) assertions.assert_found(assignment, 'No assignment with this id was found') assertions.assert_valid(assignment.student_id == principal.student_id, 'This assignment belongs to some other student') - assertions.assert_valid(assignment.state == AssignmentStateEnum.DRAFT, - 'only a draft assignment can be submitted') assertions.assert_valid(assignment.content is not None, 'assignment with empty content cannot be submitted') assignment.teacher_id = teacher_id diff --git a/requirements.txt b/requirements.txt index faf33a829..980640973 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,6 @@ marshmallow-enum==1.5.1 marshmallow-sqlalchemy==0.26.1 packaging==21.0 pluggy==1.0.0 -psycopg2-binary==2.8.6 py==1.10.0 pyparsing==2.4.7 pytest==6.2.5 @@ -30,4 +29,4 @@ toml==0.10.2 Werkzeug==2.0.1 zipp==3.5.0 zope.event==4.5.0 -zope.interface==5.4.0 +zope.interface==5.4.0 \ No newline at end of file diff --git a/tests/students_test.py b/tests/students_test.py index 612c20857..323d16235 100644 --- a/tests/students_test.py +++ b/tests/students_test.py @@ -57,3 +57,17 @@ def test_submit_assignment_student_1(client, h_student_1): assert data['student_id'] == 1 assert data['state'] == 'SUBMITTED' assert data['teacher_id'] == 2 + + +def test_assingment_resubmitt_error(client, h_student_1): + response = client.post( + '/student/assignments/submit', + headers=h_student_1, + json={ + 'id': 2, + 'teacher_id': 2 + }) + error_response = response.json + assert response.status_code == 400 + assert error_response['error'] == 'FyleError' + assert error_response["message"] == 'only a draft assignment can be submitted'