Skip to content

Commit b2d7b53

Browse files
ryan331913ryan.li0010aor
authored
feat: add backend tests (#73)
* Add flashcards api related tests * Add flashcards services related tests * Add pytest-asyncio package * Add session related testing * Add more stats related testing --------- Co-authored-by: ryan.li <[email protected]> Co-authored-by: ZorroGuardaPavos <[email protected]>
1 parent e6a7b95 commit b2d7b53

File tree

15 files changed

+2393
-29
lines changed

15 files changed

+2393
-29
lines changed

backend/pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ dev-dependencies = [
2424
"pytest>=8.3.4",
2525
"coverage>=7.8.0",
2626
"ruff>=0.9.5",
27-
"pre-commit>=4.2.0"
27+
"pre-commit>=4.2.0",
28+
"pytest-cov>=6.1.1",
29+
"pytest-asyncio>=0.26.0",
2830
]
2931

3032
[tool.hatch.build.targets.wheel]

backend/src/flashcards/services.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -314,23 +314,6 @@ def get_practice_cards(
314314
return practice_cards, count
315315

316316

317-
def get_next_card(
318-
session: Session, practice_session_id: uuid.UUID
319-
) -> tuple[Card, PracticeCard] | None:
320-
statement = (
321-
select(PracticeCard, Card)
322-
.join(Card, PracticeCard.card_id == Card.id)
323-
.where(
324-
PracticeCard.session_id == practice_session_id,
325-
PracticeCard.is_practiced.is_not(True),
326-
)
327-
.limit(1)
328-
)
329-
result = session.exec(statement).first()
330-
if result:
331-
return result[1], result[0]
332-
333-
334317
def get_practice_card(
335318
session: Session,
336319
practice_session_id: uuid.UUID,
@@ -373,12 +356,6 @@ def record_practice_card_result(
373356
return practice_card
374357

375358

376-
def get_session_statistics(
377-
session: Session, practice_session_id: uuid.UUID
378-
) -> PracticeSession:
379-
return session.get(PracticeSession, practice_session_id)
380-
381-
382359
def get_card_by_id(session: Session, card_id: uuid.UUID) -> Card | None:
383360
statement = select(Card).where(Card.id == card_id)
384361
return session.exec(statement).first()

backend/tests/flashcards/card/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)