Skip to content

Commit

Permalink
Add unit tests for session.in_scope
Browse files Browse the repository at this point in the history
  • Loading branch information
said-moj committed Mar 11, 2025
1 parent 3542075 commit 7880a88
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion tests/unit_tests/categories/test_session.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from app.categories.constants import Category, HOUSING
from app.categories.constants import Category, HOUSING, EDUCATION
from app.categories.models import CategoryAnswer


Expand Down Expand Up @@ -99,3 +99,28 @@ def test_set_category_dataclass(app, client):
session["category"] = {"code": EDUCATION.code}
assert session.category == EDUCATION
assert isinstance(session.category, Category)


def test_in_scope(client):
in_scope_answer = CategoryAnswer(
question="What is your favourite mode of transport?",
answer_value="bus",
answer_label="Bus",
next_page="categories.index",
question_page="categories.housing.homelessness",
category=HOUSING.sub.homelessness,
)
out_scope_answer = CategoryAnswer(
question="What is your favourite mode of transport?",
answer_value="car",
answer_label="Car",
next_page="categories.index",
question_page="categories.housing.homelessness",
category=EDUCATION.sub.child_young_person,
)
with client.session_transaction() as session:
assert session.in_scope is False
session.set_category_question_answer(in_scope_answer)
assert session.in_scope is True
session.set_category_question_answer(out_scope_answer)
assert session.in_scope is False

0 comments on commit 7880a88

Please sign in to comment.