|
| 1 | +from sportorg.common.otime import OTime |
| 2 | +from sportorg.language import translate |
| 3 | +from sportorg.models.memory import ( |
| 4 | + ResultSportident, |
| 5 | + Person, |
| 6 | + ResultStatus, |
| 7 | + Organization, |
| 8 | + Group, |
| 9 | + race, |
| 10 | +) |
| 11 | +from sportorg.modules.backup.sfr_results_board import get_srb_line_for_result |
| 12 | + |
| 13 | + |
| 14 | +def test_srb_generation(): |
| 15 | + res = ResultSportident() |
| 16 | + res.place = 12 |
| 17 | + res.finish_time = OTime(hour=12, minute=58, sec=59) |
| 18 | + |
| 19 | + person = Person() |
| 20 | + person.name = "Sergei" |
| 21 | + person.surname = "Petrov" |
| 22 | + person.set_bib(2023) |
| 23 | + res.person = person |
| 24 | + |
| 25 | + group = Group() |
| 26 | + group.name = "ME" |
| 27 | + person.group = group |
| 28 | + |
| 29 | + team = Organization() |
| 30 | + team.name = "SKI Team" |
| 31 | + person.organization = team |
| 32 | + |
| 33 | + line = get_srb_line_for_result(res, "\t", False, False, False) |
| 34 | + assert line == "2023\tME\t009999912:58:59\t1\tPetrov Sergei\tSKI Team\t12:58:59\n" |
| 35 | + |
| 36 | + res.rogaine_score = 300 |
| 37 | + race().set_setting("result_processing_mode", "scores") |
| 38 | + line = get_srb_line_for_result(res, "\t", True, False, False) |
| 39 | + assert ( |
| 40 | + line |
| 41 | + == f"2023\tME\t0099699300 {translate('points')} 12:58:59\t1\tPetrov Sergei\tSKI Team\t300 {translate('points')} 12:58:59\n" |
| 42 | + ) |
| 43 | + |
| 44 | + res.scores_ardf = 500 |
| 45 | + race().set_setting("result_processing_mode", "ardf") |
| 46 | + line = get_srb_line_for_result(res, "\t", False, True, False) |
| 47 | + assert ( |
| 48 | + line |
| 49 | + == f"2023\tME\t0099499500 {translate('points')} 12:58:59\t1\tPetrov Sergei\tSKI Team\t500 {translate('points')} 12:58:59\n" |
| 50 | + ) |
| 51 | + |
| 52 | + race().set_setting("result_processing_mode", "time") |
| 53 | + line = get_srb_line_for_result(res, "\t", False, False, True) |
| 54 | + assert line == "2023\tME\t029999912:58:59\t1\tPetrov Sergei\tSKI Team\t12:58:59\n" |
| 55 | + |
| 56 | + person.is_out_of_competition = True |
| 57 | + line = get_srb_line_for_result(res, "\t", False, False, False) |
| 58 | + assert line == "2023\tME\t009999912:58:59\t0\tPetrov Sergei\tSKI Team\t12:58:59\n" |
| 59 | + |
| 60 | + person.is_out_of_competition = False |
| 61 | + res.status = ResultStatus.MISSING_PUNCH |
| 62 | + res.status_comment = "DSQ" |
| 63 | + line = get_srb_line_for_result(res, "\t", False, False, False) |
| 64 | + assert line == "2023\tME\t0099999DSQ\t0\tPetrov Sergei\tSKI Team\tDSQ\n" |
0 commit comments