Skip to content

Commit a1935f2

Browse files
committed
add Swedish support
add tests for Swedish
1 parent 168ccfc commit a1935f2

2 files changed

Lines changed: 42 additions & 30 deletions

File tree

locale/Swedish.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"directive":"Förklara orsaken till felet i koden som lämnats in som läxa med enkla ord utan att upprepa.",
3+
"report_header":"Felmeddelande börjar",
4+
"report_footer":"Felmeddelande slutar",
5+
"instruction_start":"Start av uppgiftsinstruktion",
6+
"instruction_end":"Slut av uppgiftsinstruktion",
7+
"homework_start":"Start av inlämningskod för läxa",
8+
"homework_end":"Slut av inlämningskod för läxa"
9+
}

tests/test_ai_tutor.py

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import json
2-
import os
32
import pathlib
43
import sys
54

65
from typing import Callable, Dict, List, Tuple, Union
76

7+
88
import pytest
99

1010

@@ -23,7 +23,7 @@
2323

2424
@pytest.fixture
2525
def sample_report_path() -> pathlib.Path:
26-
return test_folder/'sample_report.json'
26+
return test_folder / 'sample_report.json'
2727

2828

2929
@pytest.fixture
@@ -41,7 +41,7 @@ def test_collect_longrepr__returns_non_empty(json_dict):
4141

4242
@pytest.fixture
4343
def div_zero_report_path() -> pathlib.Path:
44-
return test_folder/'json_dict_div_zero_try_except.json'
44+
return test_folder / 'json_dict_div_zero_try_except.json'
4545

4646

4747
@pytest.fixture
@@ -74,7 +74,7 @@ def test_collect_longrepr_from_multiple_reports__returns_non_empty(
7474
assert result
7575

7676

77-
@pytest.fixture(params=('Korean', 'English', 'Bahasa Indonesia', 'Chinese', 'French', 'German', 'Italian', 'Japanese', 'Nederlands', 'Spanish', 'Thai', 'Vietnamese'))
77+
@pytest.fixture(params=tuple(path.stem for path in pathlib.Path('locale').glob('*.json')))
7878
def explanation_in(request) -> str:
7979
return request.param
8080

@@ -92,6 +92,7 @@ def homework(explanation_in:str) -> Tuple[str]:
9292
'Japanese': ('宿題',),
9393
'Nederlands': ('Huiswerk',),
9494
'Spanish': ('Tarea',),
95+
'Swedish': ('Läxa',),
9596
'Thai': ('การบ้าน',),
9697
'Vietnamese': ('Bài tập',),
9798
}
@@ -116,12 +117,38 @@ def msg(explanation_in:str) -> str:
116117
'Japanese': 'メッセ',
117118
'Nederlands': 'Foutmelding', # error message
118119
'Spanish': 'Mensaje',
120+
'Swedish': 'Meddelande',
119121
'Thai': 'ข้อความ',
120122
'Vietnamese': 'thông báo', # notification
121123
}
122124
return d[explanation_in].lower()
123125

124126

127+
@pytest.fixture
128+
def instruction(explanation_in:str) -> str:
129+
d = {
130+
'Korean': ('지침',),
131+
'English': ('Instruction',),
132+
'Bahasa Indonesia': ('Petunjuk', 'Instruksi'),
133+
'Chinese': ('说明',),
134+
'French': ('instruction',),
135+
'German': ('Aufgabenanweisung',),
136+
'Italian': ('istruzione',),
137+
'Japanese': ('指示',),
138+
'Nederlands': ('instructie',),
139+
'Spanish': ('instrucción',),
140+
'Swedish': ('instruktion',),
141+
'Thai': ('แนะนำ',),
142+
'Vietnamese': ('hướng dẫn',),
143+
}
144+
return tuple(
145+
map(
146+
lambda x: x.lower(),
147+
d[explanation_in]
148+
)
149+
)
150+
151+
125152
def test_get_directive(explanation_in:str, homework:Tuple[str]):
126153
result = ai_tutor.get_directive(explanation_in=explanation_in)
127154

@@ -158,36 +185,12 @@ def test_get_report__header__footer(explanation_in:str, msg:str, func:Callable):
158185

159186
@pytest.fixture
160187
def sample_student_code_path() -> pathlib.Path:
161-
return test_folder/'sample_code.py'
188+
return test_folder / 'sample_code.py'
162189

163190

164191
@pytest.fixture
165192
def sample_readme_path() -> pathlib.Path:
166-
return test_folder/'sample_readme.md'
167-
168-
169-
@pytest.fixture
170-
def instruction(explanation_in:str) -> str:
171-
d = {
172-
'Korean': ('지침',),
173-
'English': ('Instruction',),
174-
'Bahasa Indonesia': ('Petunjuk', 'Instruksi'),
175-
'Chinese': ('说明',),
176-
'French': ('instruction',),
177-
'German': ('Aufgabenanweisung',),
178-
'Italian': ('istruzione',),
179-
'Japanese': ('指示',),
180-
'Nederlands': ('instructie',),
181-
'Spanish': ('instrucción',),
182-
'Thai': ('แนะนำ',),
183-
'Vietnamese': ('hướng dẫn',),
184-
}
185-
return tuple(
186-
map(
187-
lambda x: x.lower(),
188-
d[explanation_in]
189-
)
190-
)
193+
return test_folder / 'sample_readme.md'
191194

192195

193196
def test_get_instruction_block(

0 commit comments

Comments
 (0)