Skip to content

Commit 0dd6ec2

Browse files
committed
allow multiple expressions for homework
1 parent 8150ca5 commit 0dd6ec2

1 file changed

Lines changed: 39 additions & 18 deletions

File tree

tests/test_ai_tutor.py

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pathlib
44
import sys
55

6-
from typing import Dict, Union, List
6+
from typing import Callable, Dict, List, Tuple, Union
77

88
import pytest
99

@@ -63,18 +63,23 @@ def explanation_in(request) -> str:
6363

6464

6565
@pytest.fixture
66-
def homework(explanation_in:str) -> str:
66+
def homework(explanation_in:str) -> Tuple[str]:
6767
d = {
68-
'Korean': '숙제',
69-
'English': 'Homework',
70-
'Japanese': '宿題',
71-
'Chinese': '作业',
72-
'Spanish': 'Tarea',
73-
'French': 'Devoir',
74-
'German': 'Hausaufgabe',
75-
'Thai': 'การบ้าน',
68+
'Korean': ('숙제',),
69+
'English': ('Homework',),
70+
'Japanese': ('宿題',),
71+
'Chinese': ('作业',),
72+
'Spanish': ('Tarea',),
73+
'French': ('Devoir',),
74+
'German': ('Hausaufgabe',),
75+
'Thai': ('การบ้าน',),
7676
}
77-
return d[explanation_in].lower()
77+
return tuple(
78+
map(
79+
lambda x: x.lower(),
80+
d[explanation_in]
81+
)
82+
)
7883

7984

8085
@pytest.fixture
@@ -92,14 +97,19 @@ def msg(explanation_in:str) -> str:
9297
return d[explanation_in].lower()
9398

9499

95-
def test_get_instruction(explanation_in, homework,):
100+
def test_get_instruction(explanation_in:str, homework:Tuple[str],):
96101
result = ai_tutor.get_directive(explanation_in=explanation_in)
97102

98-
assert homework in result.lower()
103+
assert any(
104+
map(
105+
lambda x: x in result.lower(),
106+
homework
107+
)
108+
)
99109

100110

101111
@pytest.mark.parametrize("func", (ai_tutor.get_report_header, ai_tutor.get_report_footer))
102-
def test_get_report__header__footer(explanation_in, msg, func):
112+
def test_get_report__header__footer(explanation_in:str, msg:str, func:Callable):
103113

104114
result = func(explanation_in=explanation_in)
105115

@@ -135,7 +145,7 @@ def test_get_code_instruction(
135145
sample_student_code_path:pathlib.Path,
136146
sample_readme_path:pathlib.Path,
137147
explanation_in:str,
138-
homework:str,
148+
homework:Tuple[str],
139149
instruction:str,
140150
):
141151

@@ -145,7 +155,12 @@ def test_get_code_instruction(
145155
explanation_in=explanation_in
146156
).lower()
147157

148-
assert homework in result
158+
assert any(
159+
map(
160+
lambda x: x in result,
161+
homework
162+
)
163+
)
149164
assert instruction in result
150165

151166

@@ -155,7 +170,8 @@ def test_get_the_question(
155170
sample_student_code_path:pathlib.Path,
156171
sample_readme_path:pathlib.Path,
157172
explanation_in:str,
158-
homework:str, msg:str,
173+
homework:Tuple[str],
174+
msg:str,
159175
instruction:str,
160176
):
161177
result = ai_tutor.get_the_question(
@@ -165,7 +181,12 @@ def test_get_the_question(
165181
explanation_in=explanation_in,
166182
).lower()
167183

168-
assert homework in result
184+
assert any(
185+
map(
186+
lambda x: x in result,
187+
homework
188+
)
189+
)
169190
assert msg in result
170191
assert instruction in result
171192

0 commit comments

Comments
 (0)