Merge HTML final status into main data structures

This commit is contained in:
2022-11-15 18:11:40 +01:00
parent 867b18576f
commit ea6009bb0a
3 changed files with 110 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
from solo_turnier import worker
from solo_turnier import worker, html_parser
import os
import json
import pytest
@@ -216,3 +216,97 @@ def test_createHtmlLUT(mocker):
('group3', 'class3', 'dance3'): importMock3,
}
assert expected == structure
def test_mergeHtmlData(mocker):
person1 = worker.ResultPerson('Max 1', 'Mustermann', 'TSC Entenhausen')
person2 = worker.ResultPerson('Max 2', 'Mustermann', 'TSC Entenhausen')
person3 = worker.ResultPerson('Max 3', 'Mustermann', 'TSC Entenhausen')
person4 = worker.ResultPerson('Max 4', 'Mustermann', 'TSC Entenhausen')
data = {
person1: [
worker.CompetitionResult('Rumba', 'Kin.', 'Beg.', '1', '1', 1, 'Kin./Jun.', 'Beg.'),
worker.CompetitionResult('Cha Cha', 'Kin.', 'Adv.', '1', '1', 1, 'Kin.', 'Adv.'),
worker.CompetitionResult('Jive', 'Kin.', 'Beg.', '1', '2', 1, 'Kin.', 'Beg.'),
worker.CompetitionResult('Langs. Walzer', 'Kin.', 'Beg.', '1', '1', 1, 'Kin.', 'Newc./Beg.'),
],
person2: [
worker.CompetitionResult('Rumba', 'Kin.', 'Beg.', '2', '2', 2, 'Kin./Jun.', 'Beg.'),
worker.CompetitionResult('Cha Cha', 'Kin.', 'Adv.', '2', '2', 2, 'Kin.', 'Adv.'),
worker.CompetitionResult('Jive', 'Kin.', 'Beg.', '1', '2', 2, 'Kin.', 'Beg.'),
worker.CompetitionResult('Langs. Walzer', 'Kin.', 'Newc.', '1', '1', 2, 'Kin.', 'Newc./Beg.'),
],
person3: [
worker.CompetitionResult('Rumba', 'Jun.', 'Beg.', '1', '1', 3, 'Kin./Jun.', 'Beg.'),
# worker.CompetitionResult('Cha Cha', 'Jun.', 'Adv.', '1', '1', 3, 'Kin.', 'Adv.'),
# worker.CompetitionResult('Jive', 'Jun.', 'Beg.', '2', '2', 3, 'Kin.', 'Beg.'),
# worker.CompetitionResult('Langs. Walzer', 'Jun.', 'Newc./Beg.', '1', '1', 3, 'Kin.', 'Beg.'),
],
person4: [
worker.CompetitionResult('Rumba', 'Kin.', 'Beg.', '3', '3', 4, 'Kin./Jun.', 'Beg.'),
# worker.CompetitionResult('Cha Cha', 'Kin.', 'Adv.', '1', '1', 4, 'Kin.', 'Adv.'),
# worker.CompetitionResult('Jive', 'Kin.', 'Beg.', '2', '2', 4, 'Kin.', 'Beg.'),
# worker.CompetitionResult('Langs. Walzer', 'Kin.', 'Newc./Beg.', '1', '1', 4, 'Kin.', 'Beg.'),
],
}
htmlParticipant1Dance1 = html_parser.HtmlParticipant('Max 1 Mustermann', '1.', True)
htmlParticipant1Dance2 = html_parser.HtmlParticipant('Max 1 Mustermann', '1.', True)
htmlParticipant1Dance3 = html_parser.HtmlParticipant('Max 1 Mustermann', '1.-2.', True)
htmlParticipant1Dance4 = html_parser.HtmlParticipant('Max 1 Mustermann', '1.', True)
htmlParticipant2Dance1 = html_parser.HtmlParticipant('Max 2 Mustermann', '2.', True)
htmlParticipant2Dance2 = html_parser.HtmlParticipant('Max 2 Mustermann', '2.', True)
htmlParticipant2Dance3 = html_parser.HtmlParticipant('Max 2 Mustermann', '1.-2.', True)
htmlParticipant2Dance4 = html_parser.HtmlParticipant('Max 2 Mustermann', '1.', True)
htmlParticipant3Dance1 = html_parser.HtmlParticipant('Max 3 Mustermann', '1.', True)
htmlParticipant4Dance1 = html_parser.HtmlParticipant('Max 4 Mustermann', '3.', False)
htmlParticipantsDance1 = {
'1': htmlParticipant1Dance1,
'2': htmlParticipant2Dance1,
'3': htmlParticipant3Dance1,
'4': htmlParticipant4Dance1
}
htmlParticipantsDance2 = {
'1': htmlParticipant1Dance2,
'2': htmlParticipant2Dance2,
}
htmlParticipantsDance3 = {
'1': htmlParticipant1Dance3,
'2': htmlParticipant2Dance3,
}
htmlParticipantsDance4 = {
'1': htmlParticipant1Dance4,
'2': htmlParticipant2Dance4,
}
htmlCompetition1 = html_parser.HtmlImport('ETW, Solos Kin./Jun. Beginner Rumba', htmlParticipantsDance1)
htmlCompetition2 = html_parser.HtmlImport('ETW, Solos Kin. Advanced Cha Cha', htmlParticipantsDance2)
htmlCompetition3 = html_parser.HtmlImport('ETW, Solos Kinder Beginner Jive', htmlParticipantsDance3)
htmlCompetition4 = html_parser.HtmlImport('ETW, Solos Kin. Newc./Beg. Langs. Walzer', htmlParticipantsDance4)
dataWorker = worker.DataWorker()
dataWorker.mergeHtmlData(data, [htmlCompetition1, htmlCompetition2, htmlCompetition3, htmlCompetition4])
person1Finalist = [c.finalist for c in data[person1]]
person2Finalist = [c.finalist for c in data[person2]]
person3Finalist = [c.finalist for c in data[person3]]
person4Finalist = [c.finalist for c in data[person4]]
finalists = {
person1: person1Finalist,
person2: person2Finalist,
person3: person3Finalist,
person4: person4Finalist,
}
expectedFinalists = {
person1: [True, True, True, True],
person2: [True, True, True, True],
person3: [True],
person4: [False],
}
assert finalists == expectedFinalists