Skip to content

Commit f22514b

Browse files
committed
Add tests for keystring parameters
1 parent ee63cc5 commit f22514b

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

app/evaluation_tests.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,42 @@ def test_reynolds_number_is_incorrect_with_keystring(self):
7272

7373
self.assertEqual(result.get("is_correct"), False, msg=f'Response: {response}')
7474

75+
def test_reynolds_number_exact_match(self):
76+
answer, params = 'Density, Velocity, Viscosity, Length', {
77+
'keystrings': [{'string': 'velocity', 'exact_match': True}]}
78+
incorrect_responses = [
79+
'density,speed,viscosity, length',
80+
]
81+
82+
for response in incorrect_responses:
83+
result = evaluation_function(response, answer, params)
84+
85+
self.assertEqual(result.get("is_correct"), False, msg=f'Response: {response}')
86+
87+
def test_reynolds_number_should_not_contain(self):
88+
answer, params = 'Density, Velocity, Viscosity, Length', {
89+
'keystrings': [{'string': 'direction', 'should_contain': False}]}
90+
incorrect_responses = [
91+
'density,speed,viscosity, length, direction',
92+
]
93+
94+
for response in incorrect_responses:
95+
result = evaluation_function(response, answer, params)
96+
97+
self.assertEqual(result.get("is_correct"), False, msg=f'Response: {response}')
98+
99+
def test_reynolds_number_custom_feedback(self):
100+
answer, params = 'Density, Velocity, Viscosity, Length', {
101+
'keystrings': [{'string': 'banana', 'custom_feedback': 'custom feedback with the word banana'}]}
102+
incorrect_responses = [
103+
'An incorrect response',
104+
]
105+
106+
for response in incorrect_responses:
107+
result = evaluation_function(response, answer, params)
108+
109+
self.assertIn('banana', result.get("feedback"), msg=f'Response: {response}')
110+
75111
navier_stokes_answer = "The density of the film is uniform and constant, therefore the flow is incompressible. " \
76112
"Since we have incompressible flow, uniform viscosity, Newtonian fluid, " \
77113
"the most appropriate set of equations for the solution of the problem is the " \

0 commit comments

Comments
 (0)