Skip to content

Commit 6523638

Browse files
committed
more review feedback
1 parent d3165be commit 6523638

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

intbot/core/analysis/submissions.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,27 @@ def extract_answers(cls, values):
5757
# submission questions.
5858
is_submission_question = answer["submission"] is not None
5959

60-
if is_submission_question and cls.is_answer_to(answer, cls.Questions.level):
60+
if is_submission_question and cls.matches_question(answer, cls.Questions.level):
6161
values["level"] = answer["answer"]
6262

63-
if is_submission_question and cls.is_answer_to(
64-
answer, cls.Questions.outline
65-
):
63+
if is_submission_question and cls.matches_question(answer, cls.Questions.outline):
6664
values["outline"] = answer["answer"]
6765

6866
return values
6967

7068
@staticmethod
71-
def is_answer_to(answer: dict, question: str) -> bool:
69+
def matches_question(answer: dict, question: str) -> bool:
7270
"""
7371
Returns True if the answer corresponds to the question passed as the second
7472
argument.
7573
7674
Answers come in a nested structure that includes localised question
7775
text. This function is a small wrapper to encapsulate that behaviour.
7876
"""
79-
return answer.get("question", {}).get("question", {}).get("en") == question
77+
# Explicit if to make it clear it's a comparison
78+
if question == answer.get("question", {}).get("question", {}).get("en"):
79+
return True
80+
return False
8081

8182

8283
def get_latest_submissions_data() -> PretalxData:

intbot/tests/test_analysis/test_submissions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_submission_is_answer_to():
8686
]
8787

8888
if answers[0]["question"]["question"]["en"] == "Outline":
89-
assert Submission.is_answer_to(answers[0], "Outline")
89+
assert Submission.matches_question(answers[0], "Outline")
9090

9191

9292
@pytest.mark.django_db

0 commit comments

Comments
 (0)