Add more test to group consolidation method

This commit is contained in:
Christian Wolf 2022-11-15 14:19:31 +01:00
parent 0ff24494dc
commit 26d37a7237

View File

@ -102,7 +102,7 @@ def test_checkUniqueIds_True():
assert person1.id == None
assert person2.id == 1
@pytest.fixture(params=range(4))
@pytest.fixture(params=range(5))
def fixture_consolidateGroups(request):
person1 = worker.ResultPerson('Max 1', 'Mustermann', 'TSC Entenhausen')
person2 = worker.ResultPerson('Max 2', 'Mustermann', 'TSC Entenhausen')
@ -132,27 +132,45 @@ def fixture_consolidateGroups(request):
worker.CompetitionResult('Rumba', 'Kin./Jun.', 'Adv.', '2', '2', 2)
]
}
dict5 = {
person4: [
worker.CompetitionResult('Rumba', 'Kin./Jun.', 'Adv.', '2', '2', 2),
worker.CompetitionResult('Cha Cha', 'Jun./Jug.', 'Beg.', '3', '4', 2)
]
}
cases = (
(dict1|dict3, (True, False), {}, False),
(dict1|dict2|dict3, (True, True), {}, False),
(dict4, (False, False), {person4: 'Kin./Jun.'}, False),
(dict1|dict2|dict3|dict4, (False, True), {person4: 'Kin./Jun.'}, False),
(dict1|dict3, (True, False), {}),
(dict1|dict2|dict3, (True, True), {}),
(dict4, (False, False), {person4: 'Kin./Jun.'}),
(dict1|dict2|dict3|dict4, (False, True), {person4: 'Kin./Jun.'}),
(dict5, (True, True), {person4: 'Jun.'}),
)
return cases[request.param]
@pytest.fixture
def fixture_consolidateGroups_fail():
person5 = worker.ResultPerson('Max 5', 'Mustermann', 'TSC Entenhausen')
@pytest.fixture(params=range(2))
def fixture_consolidateGroups_fail(request, fixture_consolidateGroups):
person = worker.ResultPerson('Max 5', 'Mustermann', 'TSC Entenhausen')
dict5 = {
person5: [
dict1 = {
person: [
worker.CompetitionResult('Rumba', 'Kin.', 'Adv.', '2', '2', 2),
worker.CompetitionResult('Jive', 'Jun.', 'Beg.', '1', '1', 3)
]
}
return (dict5, person5)
dict2 = {
person: [
worker.CompetitionResult('Rumba', 'Kin.', 'Adv.', '2', '2', 2),
worker.CompetitionResult('Jive', 'Hgr', 'Beg.', '1', '1', 3)
]
}
cases = (
dict1 | fixture_consolidateGroups[0],
dict2 | fixture_consolidateGroups[0]
)
return cases[request.param]
def test_consolidateGroups(fixture_consolidateGroups):
data = fixture_consolidateGroups[0]
@ -163,8 +181,8 @@ def test_consolidateGroups(fixture_consolidateGroups):
for person in data:
assert person.group == fixture_consolidateGroups[2].get(person, 'Kin.')
def test_consolidateGroups_failing(fixture_consolidateGroups, fixture_consolidateGroups_fail):
data = fixture_consolidateGroups[0] | fixture_consolidateGroups_fail[0]
def test_consolidateGroups_failing(fixture_consolidateGroups_fail):
data = fixture_consolidateGroups_fail
dataWorker = worker.DataWorker()
with pytest.raises(Exception):