Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/api/v1/exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from app.db.model.exercise import Exercise, ExerciseProgress, Competition, TestCase

router = APIRouter(
prefix="/exercise",
tags=["exercise"],
prefix="/exercises",
tags=["exercises"],
)


Expand Down Expand Up @@ -123,7 +123,7 @@ async def create_exercise(new_exercise: ExerciseCreate, session: AsyncSession =
return ExerciseRead(**exercise.to_dict())


@router.post("/{exercise_id}/test-case", response_model=TestCaseRead)
@router.post("/{exercise_id}/test-cases", response_model=TestCaseRead)
async def create_test_case(exercise_id: int, new_test_case: TestCaseCreate,
session: AsyncSession = Depends(get_session)) -> TestCaseRead:
test_case = TestCase(exercise_id=exercise_id, **new_test_case.model_dump())
Expand All @@ -135,7 +135,7 @@ async def create_test_case(exercise_id: int, new_test_case: TestCaseCreate,
return TestCaseRead(**test_case.to_dict())


@router.get("/{exercise_id}/test-case", response_model=list[TestCaseRead], status_code=status.HTTP_200_OK)
@router.get("/{exercise_id}/test-cases", response_model=list[TestCaseRead], status_code=status.HTTP_200_OK)
async def get_test_cases(exercise_id: int, session: AsyncSession = Depends(get_session)) -> list[TestCaseRead]:
statement = select(TestCase).where(TestCase.exercise_id == exercise_id)
result = await session.execute(statement)
Expand Down
4 changes: 2 additions & 2 deletions app/api/v1/grading.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from app.mq.message_queue import get_mq_channel

router = APIRouter(
prefix="/submission",
tags=["submission"],
prefix="/submissions",
tags=["submissions"],
)


Expand Down
4 changes: 2 additions & 2 deletions app/api/v1/logging_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from app.db.model.tan import Tan

router = APIRouter(
prefix="/logging-event",
tags=["logging event"],
prefix="/logging-events",
tags=["logging events"],
)


Expand Down
2 changes: 1 addition & 1 deletion app/api/v1/tan.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from app.db.model.tan import Tan

router = APIRouter(
prefix="/tan",
prefix="/tans",
tags=["tan"],
)

Expand Down
16 changes: 8 additions & 8 deletions tests/test_exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_get_exercise(self):
app.dependency_overrides[get_session] = get_override_dependency(self.engine)
client = TestClient(app)

response = client.get("/exercise/1")
response = client.get("/exercises/1")

assert response.json() == EXERCISES[0]
assert response.status_code == 200
Expand All @@ -40,7 +40,7 @@ def test_post_exercise(self):
"next_exercise_id": None,
}

response = client.post("/exercise", json=new_exercise)
response = client.post("/exercises", json=new_exercise)
result_exercise = response.json()

print(result_exercise)
Expand All @@ -55,7 +55,7 @@ def test_get_current_exercise(self):
app.dependency_overrides[get_session] = get_override_dependency(self.engine)
client = TestClient(app)

response = client.get("/exercise/current", params={"tan_code": "test-tan-1"})
response = client.get("/exercises/current", params={"tan_code": "test-tan-1"})

assert response.status_code == 200
assert response.json() == EXERCISES[1]
Expand All @@ -64,15 +64,15 @@ def test_get_current_exercise_with_none_existing_tan(self):
app.dependency_overrides[get_session] = get_override_dependency(self.engine)
client = TestClient(app)

response = client.get("/exercise/current", params={"tan_code": "non-existing-tan"})
response = client.get("/exercises/current", params={"tan_code": "non-existing-tan"})

assert response.status_code == status.HTTP_404_NOT_FOUND

def test_get_current_exercise_with_missing_current_progress_entry_1(self):
app.dependency_overrides[get_session] = get_override_dependency(self.engine)
client = TestClient(app)

response = client.get("/exercise/current", params={"tan_code": "test-tan-2"})
response = client.get("/exercises/current", params={"tan_code": "test-tan-2"})

assert response.status_code == 200
assert response.json() == EXERCISES[2]
Expand All @@ -81,7 +81,7 @@ def test_get_current_exercise_with_missing_current_progress_entry_2(self):
app.dependency_overrides[get_session] = get_override_dependency(self.engine)
client = TestClient(app)

response = client.get("/exercise/current", params={"tan_code": "test-tan-3"})
response = client.get("/exercises/current", params={"tan_code": "test-tan-3"})

assert response.status_code == 200
assert response.json() == EXERCISES[0]
Expand Down Expand Up @@ -110,7 +110,7 @@ def test_post_test_case(self):
"expected_output": ["30"]
}

response = client.post("/exercise/1/test-case", json=new_test_case)
response = client.post("/exercises/1/test-cases", json=new_test_case)

result_test_case = response.json()

Expand All @@ -126,7 +126,7 @@ def test_get_test_case(self):
app.dependency_overrides[get_session] = get_override_dependency(self.engine)
client = TestClient(app)

response = client.get("/exercise/2/test-case")
response = client.get("/exercises/2/test-cases")
result_test_cases = response.json()

expected_test_case = {
Expand Down
4 changes: 2 additions & 2 deletions tests/test_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def get_mq_connection_override() -> Connection:
"solution_code": "addi r0 r0 r0"
}

response = client.post("/submission", json=submission)
response = client.post("/submissions", json=submission)

print(response.json())

Expand All @@ -65,7 +65,7 @@ async def get_mq_connection_override() -> Connection:
"solution_code": "addi r0 r0 r0"
}

response = client.post("/submission", json=submission)
response = client.post("/submissions", json=submission)

print(response.json())

Expand Down
4 changes: 2 additions & 2 deletions tests/test_tan.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_get_tan(self):
app.dependency_overrides[get_session] = get_override_dependency(self.engine)
client = TestClient(app)

response = client.get("/tan/123456")
response = client.get("/tans/123456")

assert response.json() == {"code": "123456", "valid_from": None, "valid_to": None}
assert response.status_code == 200
Expand All @@ -36,6 +36,6 @@ def test_get_none_existing_tan(self):
app.dependency_overrides[get_session] = get_override_dependency(self.engine)
client = TestClient(app)

response = client.get("/tan/not-existing-tan")
response = client.get("/tans/not-existing-tan")

assert response.status_code == 404
14 changes: 7 additions & 7 deletions tests/util/demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,23 @@
EXERCISE_TEST_CASES = {
2: [
{
"title": "read val to r1 and r2 and store sum in r3 + output",
"title": "4 * 5 = 20",
"precondition": {
"registers": {
"pc": 0,
"pc": 0
},
"memory": {}
},
"postcondition": {
"registers": {
"r1": 10,
"r2": 20,
"r3": 30,
"r1": 4,
"r2": 5,
"r3": 20
},
"memory": {}
},
"user_input": ["10", "20"],
"expected_output": ["30"]
"user_input": ["4", "5"],
"expected_output": ["20"]
}
]
}