Add dedicated class and group for competitions for comparirision with HTML
This commit is contained in:
parent
9fd34353f1
commit
8301ae206f
@ -23,7 +23,7 @@ def test_csvExtractor(fixture_csvExtractor):
|
||||
assert mapped[i].__dict__ == elem
|
||||
|
||||
def test_extractPersonFromRow():
|
||||
row = worker.ResultRow('Max', 'Mustermann', 'TSC Entenhausen', '2', 'Kin', 'Adv.', 'Rumba', '2', '2')
|
||||
row = worker.ResultRow('Max', 'Mustermann', 'TSC Entenhausen', '2', 'Kin', 'Adv.', 'Rumba', '2', '2', 'Kin.', 'Beg./Adv.')
|
||||
person = worker.ResultPerson.extractFromResultRow(row)
|
||||
expected = {
|
||||
'firstName': 'Max',
|
||||
@ -36,8 +36,8 @@ def test_extractPersonFromRow():
|
||||
assert person.__dict__ == expected
|
||||
|
||||
def test_extractCompetitionFromRow():
|
||||
row = worker.ResultRow('Max', 'Mustermann', 'TSC Entenhausen', '2', 'Kin', 'Adv.', 'Rumba', '2', '2')
|
||||
person = worker.CompetitionResult.extractFromResultRow(row)
|
||||
row = worker.ResultRow('Max', 'Mustermann', 'TSC Entenhausen', '2', 'Kin', 'Adv.', 'Rumba', '2', '2', 'Kin.', 'Beg./Adv.')
|
||||
competition = worker.CompetitionResult.extractFromResultRow(row)
|
||||
expected = {
|
||||
'dance': 'Rumba',
|
||||
'class_': 'Adv.',
|
||||
@ -45,26 +45,28 @@ def test_extractCompetitionFromRow():
|
||||
'place': '2',
|
||||
'placeTo': '2',
|
||||
'id': 2,
|
||||
'finalist': None
|
||||
'finalist': None,
|
||||
'competitionGroup': 'Kin.',
|
||||
'competitionClass': 'Beg./Adv.'
|
||||
}
|
||||
assert person.__dict__ == expected
|
||||
assert competition.__dict__ == expected
|
||||
|
||||
def test_combineRowsByPerson():
|
||||
rows = [
|
||||
worker.ResultRow('Max', 'Mustermann', 'TSC Entenhausen', '2', 'Kin', 'Adv.', 'Cha Cha', '-', '-'),
|
||||
worker.ResultRow('Max', 'Mustermann', 'TSC Entenhausen', '2', 'Kin', 'Adv.', 'Rumba', '2', '2'),
|
||||
worker.ResultRow('Max', 'Mustermann', 'TSC Entenhausen', '2', 'Kin', 'Beg.', 'Jive', '1', '1'),
|
||||
worker.ResultRow('Maxime', 'Musterfrau', '1. SC Entenhausen', '1', 'Kin', 'Adv.', 'Rumba', '1', '1')
|
||||
worker.ResultRow('Max', 'Mustermann', 'TSC Entenhausen', '2', 'Kin', 'Adv.', 'Cha Cha', '-', '-', 'Kin.', 'Adv.'),
|
||||
worker.ResultRow('Max', 'Mustermann', 'TSC Entenhausen', '2', 'Kin', 'Adv.', 'Rumba', '2', '2', 'Kin.', 'Adv.'),
|
||||
worker.ResultRow('Max', 'Mustermann', 'TSC Entenhausen', '2', 'Kin', 'Beg.', 'Jive', '1', '1', 'Kin.', 'Beg.'),
|
||||
worker.ResultRow('Maxime', 'Musterfrau', '1. SC Entenhausen', '1', 'Kin', 'Adv.', 'Rumba', '1', '1', 'Kin.', 'Adv.')
|
||||
]
|
||||
dataWorker = worker.DataWorker()
|
||||
result = dataWorker.combineRowsByPerson(rows)
|
||||
expected = {
|
||||
worker.ResultPerson('Max', 'Mustermann', 'TSC Entenhausen'): [
|
||||
worker.CompetitionResult('Rumba', 'Kin', 'Adv.', '2', '2', '2'),
|
||||
worker.CompetitionResult('Jive', 'Kin', 'Beg.', '1', '1', '2')
|
||||
worker.CompetitionResult('Rumba', 'Kin', 'Adv.', '2', '2', '2', 'Kin.', 'Adv.'),
|
||||
worker.CompetitionResult('Jive', 'Kin', 'Beg.', '1', '1', '2', 'Kin.', 'Beg.')
|
||||
],
|
||||
worker.ResultPerson('Maxime', 'Musterfrau', '1. SC Entenhausen'): [
|
||||
worker.CompetitionResult('Rumba', 'Kin', 'Adv.', '1', '1', '1')
|
||||
worker.CompetitionResult('Rumba', 'Kin', 'Adv.', '1', '1', '1', 'Kin.', 'Adv.')
|
||||
]
|
||||
}
|
||||
assert result == expected
|
||||
@ -74,11 +76,11 @@ def test_checkUniqueIds_True():
|
||||
person2 = worker.ResultPerson('Maxime', 'Musterfrau', '1. SC Entenhausen')
|
||||
data = {
|
||||
person1: [
|
||||
worker.CompetitionResult('Rumba', 'Kin', 'Adv.', '2', '2', 2),
|
||||
worker.CompetitionResult('Jive', 'Kin', 'Beg.', '1', '1', 2)
|
||||
worker.CompetitionResult('Rumba', 'Kin', 'Adv.', '2', '2', 2, 'Kin.', 'Adv.'),
|
||||
worker.CompetitionResult('Jive', 'Kin', 'Beg.', '1', '1', 2, 'Kin.', 'Beg.')
|
||||
],
|
||||
person2: [
|
||||
worker.CompetitionResult('Rumba', 'Kin', 'Adv.', '1', '1', 1)
|
||||
worker.CompetitionResult('Rumba', 'Kin', 'Adv.', '1', '1', 1, 'Kin.', 'Adv.')
|
||||
]
|
||||
}
|
||||
dataWorker = worker.DataWorker()
|
||||
@ -86,16 +88,16 @@ def test_checkUniqueIds_True():
|
||||
assert person1.id == 2
|
||||
assert person2.id == 1
|
||||
|
||||
def test_checkUniqueIds_True():
|
||||
def test_checkUniqueIds_False():
|
||||
person1 = worker.ResultPerson('Max', 'Mustermann', 'TSC Entenhausen')
|
||||
person2 = worker.ResultPerson('Maxime', 'Musterfrau', '1. SC Entenhausen')
|
||||
data = {
|
||||
person1: [
|
||||
worker.CompetitionResult('Rumba', 'Kin', 'Adv.', '2', '2', 2),
|
||||
worker.CompetitionResult('Jive', 'Kin', 'Beg.', '1', '1', 3)
|
||||
worker.CompetitionResult('Rumba', 'Kin', 'Adv.', '2', '2', 2, 'Kin.', 'Adv.'),
|
||||
worker.CompetitionResult('Jive', 'Kin', 'Beg.', '1', '1', 3, 'Kin.', 'Beg.')
|
||||
],
|
||||
person2: [
|
||||
worker.CompetitionResult('Rumba', 'Kin', 'Adv.', '1', '1', 1)
|
||||
worker.CompetitionResult('Rumba', 'Kin', 'Adv.', '1', '1', 1, 'Kin.', 'Adv.')
|
||||
]
|
||||
}
|
||||
dataWorker = worker.DataWorker()
|
||||
@ -113,30 +115,30 @@ def fixture_consolidateGroups(request):
|
||||
|
||||
dict1 = {
|
||||
person1: [
|
||||
worker.CompetitionResult('Rumba', 'Kin.', 'Adv.', '2', '2', 2),
|
||||
worker.CompetitionResult('Jive', 'Kin.', 'Beg.', '1', '1', 3)
|
||||
worker.CompetitionResult('Rumba', 'Kin.', 'Adv.', '2', '2', 2, 'Kin.', 'Adv.'),
|
||||
worker.CompetitionResult('Jive', 'Kin.', 'Beg.', '1', '1', 3, 'Kin.', 'Beg.')
|
||||
]
|
||||
}
|
||||
dict2 = {
|
||||
person2: [
|
||||
worker.CompetitionResult('Rumba', 'Kin.', 'Adv.', '2', '2', 2),
|
||||
worker.CompetitionResult('Jive', 'Kin./Jun.', 'Beg.', '1', '1', 3)
|
||||
worker.CompetitionResult('Rumba', 'Kin.', 'Adv.', '2', '2', 2, 'Kin.', 'Adv.'),
|
||||
worker.CompetitionResult('Jive', 'Kin./Jun.', 'Beg.', '1', '1', 3, 'Kin./Jun.', 'Beg.')
|
||||
]
|
||||
}
|
||||
dict3 = {
|
||||
person3: [
|
||||
worker.CompetitionResult('Rumba', 'Kin.', 'Adv.', '2', '2', 2)
|
||||
worker.CompetitionResult('Rumba', 'Kin.', 'Adv.', '2', '2', 2, 'Kin.', 'Adv.')
|
||||
]
|
||||
}
|
||||
dict4 = {
|
||||
person4: [
|
||||
worker.CompetitionResult('Rumba', 'Kin./Jun.', 'Adv.', '2', '2', 2)
|
||||
worker.CompetitionResult('Rumba', 'Kin./Jun.', 'Adv.', '2', '2', 2, 'Kin./Jun.', 'Adv.')
|
||||
]
|
||||
}
|
||||
dict5 = {
|
||||
person4: [
|
||||
worker.CompetitionResult('Rumba', 'Kin./Jun.', 'Adv.', '2', '2', 2),
|
||||
worker.CompetitionResult('Cha Cha', 'Jun./Jug.', 'Beg.', '3', '4', 2)
|
||||
worker.CompetitionResult('Rumba', 'Kin./Jun.', 'Adv.', '2', '2', 2, 'Kin./Jun.', 'Adv.'),
|
||||
worker.CompetitionResult('Cha Cha', 'Jun./Jug.', 'Beg.', '3', '4', 2, 'Jun./Jug.', 'Beg.')
|
||||
]
|
||||
}
|
||||
|
||||
@ -155,15 +157,15 @@ def fixture_consolidateGroups_fail(request, fixture_consolidateGroups):
|
||||
|
||||
dict1 = {
|
||||
person: [
|
||||
worker.CompetitionResult('Rumba', 'Kin.', 'Adv.', '2', '2', 2),
|
||||
worker.CompetitionResult('Jive', 'Jun.', 'Beg.', '1', '1', 3)
|
||||
worker.CompetitionResult('Rumba', 'Kin.', 'Adv.', '2', '2', 2, 'Kin.', 'Adv.'),
|
||||
worker.CompetitionResult('Jive', 'Jun.', 'Beg.', '1', '1', 3, 'Jun.', 'Adv.')
|
||||
]
|
||||
}
|
||||
|
||||
dict2 = {
|
||||
person: [
|
||||
worker.CompetitionResult('Rumba', 'Kin.', 'Adv.', '2', '2', 2),
|
||||
worker.CompetitionResult('Jive', 'Hgr', 'Beg.', '1', '1', 3)
|
||||
worker.CompetitionResult('Rumba', 'Kin.', 'Adv.', '2', '2', 2, 'Kin.', 'Adv.'),
|
||||
worker.CompetitionResult('Jive', 'Hgr', 'Beg.', '1', '1', 3, 'Hgr', 'Adv.')
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,9 @@
|
||||
"place": "1",
|
||||
"placeTo": "1",
|
||||
"group": "Kin.",
|
||||
"class_": "Beginner"
|
||||
"class_": "Beginner",
|
||||
"competitionGroup": "Kin.",
|
||||
"competitionClass": "Newc./Beg."
|
||||
},
|
||||
{
|
||||
"dance": "Cha Cha",
|
||||
@ -21,7 +23,9 @@
|
||||
"place": "3",
|
||||
"placeTo": "3",
|
||||
"group": "Kin.",
|
||||
"class_": "Beginner"
|
||||
"class_": "Beginner",
|
||||
"competitionGroup": "Kin.",
|
||||
"competitionClass": "Newc./Beg."
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import logging
|
||||
|
||||
class ResultRow:
|
||||
def __init__(self, firstName, lastName, club, id, group, class_, dance, place, placeTo):
|
||||
def __init__(self, firstName, lastName, club, id, group, class_, dance, place, placeTo, competitionGroup, competitionClass):
|
||||
self.firstName = firstName
|
||||
self.lastName = lastName
|
||||
self.name = f'{firstName} {lastName}'
|
||||
@ -12,6 +12,8 @@ class ResultRow:
|
||||
self.dance = dance
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
||||
self.competitionGroup = competitionGroup
|
||||
self.competitionClass = competitionClass
|
||||
|
||||
class ResultPerson:
|
||||
def __init__(self, firstName, lastName, club, id = None, group = None):
|
||||
@ -52,13 +54,15 @@ class ResultPerson:
|
||||
return text.__hash__()
|
||||
|
||||
class CompetitionResult:
|
||||
def __init__(self, dance, group, class_, place, placeTo, id):
|
||||
def __init__(self, dance, group, class_, place, placeTo, id, competitionGroup, competitionClass):
|
||||
self.dance = dance
|
||||
self.group = group
|
||||
self.class_ = class_
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
||||
self.id = int(id)
|
||||
self.competitionGroup = competitionGroup
|
||||
self.competitionClass = competitionClass
|
||||
self.finalist = None
|
||||
|
||||
@staticmethod
|
||||
@ -68,7 +72,9 @@ class CompetitionResult:
|
||||
group=row.group,
|
||||
class_=row.class_,
|
||||
place=row.place, placeTo=row.placeTo,
|
||||
id=row.id
|
||||
id=row.id,
|
||||
competitionGroup=row.competitionGroup,
|
||||
competitionClass=row.competitionClass
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
@ -89,8 +95,8 @@ class CompetitionResult:
|
||||
|
||||
return (
|
||||
self.dance == o.dance and
|
||||
self.class_ == o.class_ and
|
||||
self.group == o.group and
|
||||
self.competitionClass == o.competitionClass and
|
||||
self.competitionGroup == o.competitionGroup and
|
||||
self.place == o.place and self.placeTo == o.placeTo and
|
||||
self.id == o.id
|
||||
)
|
||||
@ -104,6 +110,8 @@ class CSVExtractor:
|
||||
|
||||
def __processRow(row):
|
||||
result = ResultRow(
|
||||
competitionGroup=row[2],
|
||||
competitionClass=row[3],
|
||||
dance=row[4],
|
||||
id=row[5],
|
||||
firstName=row[6], lastName=row[7],
|
||||
|
Loading…
Reference in New Issue
Block a user