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