This commit is contained in:
@@ -179,3 +179,61 @@ class TestThroughTheForm:
|
||||
evaluation = Evaluation.query.one()
|
||||
assert evaluation.mecanics_score is None
|
||||
assert evaluation.overall_score == 4
|
||||
|
||||
|
||||
class TestBatchEvaluate:
|
||||
"""The batch page drives the same two helpers the single-player form does,
|
||||
through ``{field}_{player_id}`` names. The helpers were lost once, in a
|
||||
refactor, and the page 500'd on every POST until someone noticed."""
|
||||
|
||||
def _submit(self, client, setup, **fields):
|
||||
data = {'player_ids': [str(setup['player_id'])]}
|
||||
data.update(fields)
|
||||
return client.post(
|
||||
f'/evaluations/{setup["tryout_id"]}/batch',
|
||||
data=data,
|
||||
follow_redirects=True,
|
||||
)
|
||||
|
||||
def test_a_valid_batch_evaluation_is_stored(self, app, client, evaluation_setup):
|
||||
pid = evaluation_setup['player_id']
|
||||
self._submit(
|
||||
client,
|
||||
evaluation_setup,
|
||||
**{
|
||||
f'mecanics_score_{pid}': '8',
|
||||
f'mental_score_{pid}': '6',
|
||||
f'comments_{pid}': 'Solid.',
|
||||
},
|
||||
)
|
||||
|
||||
with app.app_context():
|
||||
evaluation = Evaluation.query.one()
|
||||
assert evaluation.mecanics_score == 8
|
||||
assert evaluation.overall_score == 7
|
||||
assert evaluation.comments == 'Solid.'
|
||||
assert evaluation.position_recommendation is None
|
||||
|
||||
def test_an_out_of_range_batch_score_stores_nothing(self, app, client, evaluation_setup):
|
||||
pid = evaluation_setup['player_id']
|
||||
self._submit(
|
||||
client,
|
||||
evaluation_setup,
|
||||
**{f'mecanics_score_{pid}': '11', f'mental_score_{pid}': '6'},
|
||||
)
|
||||
|
||||
with app.app_context():
|
||||
assert Evaluation.query.count() == 0
|
||||
|
||||
def test_a_second_batch_submission_replaces_the_first(self, app, client, evaluation_setup):
|
||||
pid = evaluation_setup['player_id']
|
||||
self._submit(
|
||||
client, evaluation_setup, **{f'mecanics_score_{pid}': '8', f'mental_score_{pid}': '4'}
|
||||
)
|
||||
self._submit(
|
||||
client, evaluation_setup, **{f'mecanics_score_{pid}': '4', f'mental_score_{pid}': '4'}
|
||||
)
|
||||
|
||||
with app.app_context():
|
||||
evaluation = Evaluation.query.one()
|
||||
assert evaluation.overall_score == 4
|
||||
|
||||
Reference in New Issue
Block a user