Fix draw tests since we updated the repartition algorithm
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
8777c562dd
commit
4ea93d3426
|
@ -75,7 +75,7 @@ class TestDraw(TestCase):
|
|||
self.assertFalse(await Draw.objects.filter(tournament=self.tournament).aexists())
|
||||
|
||||
# Now start the draw
|
||||
await communicator.send_json_to({'tid': tid, 'type': 'start_draw', 'fmt': '3+4+5'})
|
||||
await communicator.send_json_to({'tid': tid, 'type': 'start_draw', 'fmt': '4+5+3'})
|
||||
|
||||
# Receive data after the start
|
||||
self.assertEqual((await communicator.receive_json_from())['type'], 'alert')
|
||||
|
@ -93,7 +93,7 @@ class TestDraw(TestCase):
|
|||
{'tid': tid, 'type': 'dice_visibility', 'visible': True})
|
||||
self.assertEqual((await communicator.receive_json_from())['type'], 'alert')
|
||||
self.assertEqual(await communicator.receive_json_from(),
|
||||
{'tid': tid, 'type': 'draw_start', 'fmt': [5, 4, 3],
|
||||
{'tid': tid, 'type': 'draw_start', 'fmt': [3, 4, 5],
|
||||
'trigrams': ['AAA', 'BBB', 'CCC', 'DDD', 'EEE', 'FFF',
|
||||
'GGG', 'HHH', 'III', 'JJJ', 'KKK', 'LLL']})
|
||||
self.assertEqual((await communicator.receive_json_from())['type'], 'set_info')
|
||||
|
@ -181,8 +181,8 @@ class TestDraw(TestCase):
|
|||
.aget(number=1, draw=draw)
|
||||
p = r.current_pool
|
||||
self.assertEqual(p.letter, 1)
|
||||
self.assertEqual(p.size, 5)
|
||||
self.assertEqual(await p.teamdraw_set.acount(), 5)
|
||||
self.assertEqual(p.size, 3)
|
||||
self.assertEqual(await p.teamdraw_set.acount(), 3)
|
||||
self.assertEqual(p.current_team, None)
|
||||
|
||||
# Render page
|
||||
|
@ -292,7 +292,7 @@ class TestDraw(TestCase):
|
|||
self.assertIsNone(td.purposed)
|
||||
self.assertEqual(td.rejected, [purposed])
|
||||
|
||||
for i in range(4):
|
||||
for i in range(2):
|
||||
# Next team
|
||||
p: Pool = await Pool.objects.prefetch_related('current_team__participation__team').aget(round=r, letter=1)
|
||||
td = p.current_team
|
||||
|
@ -411,8 +411,6 @@ class TestDraw(TestCase):
|
|||
td: TeamDraw = await TeamDraw.objects.prefetch_related('participation__team').aget(pk=td.pk)
|
||||
self.assertIsNone(td.purposed)
|
||||
|
||||
# Reorder the pool since there are 5 teams
|
||||
self.assertEqual((await communicator.receive_json_from())['type'], 'reorder_poule')
|
||||
self.assertEqual(await communicator.receive_json_from(),
|
||||
{'tid': tid, 'type': 'dice_visibility', 'visible': True})
|
||||
self.assertEqual((await communicator.receive_json_from())['type'], 'set_info')
|
||||
|
@ -510,8 +508,8 @@ class TestDraw(TestCase):
|
|||
.aget(number=1, draw=draw)
|
||||
p = r.current_pool
|
||||
self.assertEqual(p.letter, 3)
|
||||
self.assertEqual(p.size, 3)
|
||||
self.assertEqual(await p.teamdraw_set.acount(), 3)
|
||||
self.assertEqual(p.size, 5)
|
||||
self.assertEqual(await p.teamdraw_set.acount(), 5)
|
||||
self.assertEqual(p.current_team, None)
|
||||
self.assertEqual(await communicator.receive_json_from(),
|
||||
{'tid': tid, 'type': 'set_active', 'round': 1, 'poule': 'C', 'team': None})
|
||||
|
@ -532,7 +530,7 @@ class TestDraw(TestCase):
|
|||
|
||||
self.assertEqual((await communicator.receive_json_from())['type'], 'set_info')
|
||||
|
||||
for i in range(3):
|
||||
for i in range(5):
|
||||
# Next team
|
||||
p: Pool = await Pool.objects.prefetch_related('current_team__participation__team').aget(round=r, letter=3)
|
||||
td = p.current_team
|
||||
|
@ -562,10 +560,11 @@ class TestDraw(TestCase):
|
|||
self.assertIsNotNone(td.purposed)
|
||||
self.assertIn(td.purposed, range(1, len(settings.PROBLEMS) + 1))
|
||||
# Lower problems are already accepted
|
||||
self.assertGreaterEqual(td.purposed, i + 1)
|
||||
self.assertGreaterEqual(td.purposed, 1 + i // 2)
|
||||
|
||||
# Assume that this is the problem is i for the team i
|
||||
td.purposed = i + 1
|
||||
# Assume that this is the problem is i / 2 for the team i (there are 5 teams)
|
||||
# We force to have duplicates
|
||||
td.purposed = 1 + i // 2
|
||||
await td.asave()
|
||||
|
||||
# Render page
|
||||
|
@ -577,11 +576,11 @@ class TestDraw(TestCase):
|
|||
self.assertEqual(await communicator.receive_json_from(),
|
||||
{'tid': tid, 'type': 'buttons_visibility', 'visible': False})
|
||||
self.assertEqual(await communicator.receive_json_from(),
|
||||
{'tid': tid, 'type': 'set_problem', 'round': 1, 'team': trigram, 'problem': i + 1})
|
||||
{'tid': tid, 'type': 'set_problem', 'round': 1, 'team': trigram, 'problem': 1 + i // 2})
|
||||
td: TeamDraw = await TeamDraw.objects.prefetch_related('participation__team').aget(pk=td.pk)
|
||||
self.assertIsNone(td.purposed)
|
||||
self.assertEqual(td.accepted, i + 1)
|
||||
if i == 2:
|
||||
self.assertEqual(td.accepted, 1 + i // 2)
|
||||
if i == 4:
|
||||
break
|
||||
self.assertEqual(await communicator.receive_json_from(),
|
||||
{'tid': tid, 'type': 'box_visibility', 'visible': True})
|
||||
|
@ -591,6 +590,9 @@ class TestDraw(TestCase):
|
|||
resp = await self.async_client.get(reverse('draw:index'))
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
|
||||
# Reorder the pool since there are 5 teams
|
||||
self.assertEqual((await communicator.receive_json_from())['type'], 'reorder_poule')
|
||||
|
||||
# Start round 2
|
||||
draw: Draw = await Draw.objects.prefetch_related(
|
||||
'current_round__current_pool__current_team__participation__team').aget(tournament=self.tournament)
|
||||
|
@ -624,7 +626,7 @@ class TestDraw(TestCase):
|
|||
.aget(draw=draw, number=2)
|
||||
p = r.current_pool
|
||||
self.assertEqual(p.letter, i + 1)
|
||||
self.assertEqual(p.size, 5 - i)
|
||||
self.assertEqual(p.size, i + 3)
|
||||
|
||||
self.assertEqual(await communicator.receive_json_from(),
|
||||
{'tid': tid, 'type': 'set_active', 'round': 2, 'poule': chr(65 + i), 'team': None})
|
||||
|
@ -642,7 +644,7 @@ class TestDraw(TestCase):
|
|||
resp = await communicator.receive_json_from()
|
||||
self.assertEqual(resp['type'], 'set_info')
|
||||
|
||||
for j in range(5 - i):
|
||||
for j in range(3 + i):
|
||||
# Next team
|
||||
p: Pool = await Pool.objects.prefetch_related('current_team__participation__team').aget(round=r,
|
||||
letter=i + 1)
|
||||
|
@ -685,13 +687,13 @@ class TestDraw(TestCase):
|
|||
self.assertEqual((await communicator.receive_json_from())['type'], 'set_problem')
|
||||
td: TeamDraw = await TeamDraw.objects.prefetch_related('participation__team').aget(pk=td.pk)
|
||||
self.assertIsNone(td.purposed)
|
||||
if j == 4 - i:
|
||||
if j == 2 + i:
|
||||
break
|
||||
self.assertEqual(await communicator.receive_json_from(),
|
||||
{'tid': tid, 'type': 'box_visibility', 'visible': True})
|
||||
self.assertEqual((await communicator.receive_json_from())['type'], 'set_info')
|
||||
|
||||
if i == 0:
|
||||
if i == 2:
|
||||
# Reorder the pool since there are 5 teams
|
||||
self.assertEqual((await communicator.receive_json_from())['type'], 'reorder_poule')
|
||||
if i < 2:
|
||||
|
@ -738,20 +740,20 @@ class TestDraw(TestCase):
|
|||
draw = Draw.objects.create(tournament=self.tournament)
|
||||
r1 = Round.objects.create(draw=draw, number=1)
|
||||
r2 = Round.objects.create(draw=draw, number=2)
|
||||
p11 = Pool.objects.create(round=r1, letter=1, size=5)
|
||||
p11 = Pool.objects.create(round=r1, letter=1, size=3)
|
||||
p12 = Pool.objects.create(round=r1, letter=2, size=4)
|
||||
p13 = Pool.objects.create(round=r1, letter=3, size=3)
|
||||
p21 = Pool.objects.create(round=r2, letter=1, size=5)
|
||||
p13 = Pool.objects.create(round=r1, letter=3, size=5)
|
||||
p21 = Pool.objects.create(round=r2, letter=1, size=3)
|
||||
p22 = Pool.objects.create(round=r2, letter=2, size=4)
|
||||
p23 = Pool.objects.create(round=r2, letter=3, size=3)
|
||||
p23 = Pool.objects.create(round=r2, letter=3, size=5)
|
||||
tds = []
|
||||
for i, team in enumerate(self.teams):
|
||||
tds.append(TeamDraw.objects.create(participation=team.participation,
|
||||
round=r1,
|
||||
pool=p11 if i < 5 else p12 if i < 9 else p13))
|
||||
pool=p11 if i < 3 else p12 if i < 7 else p13))
|
||||
tds.append(TeamDraw.objects.create(participation=team.participation,
|
||||
round=r2,
|
||||
pool=p21) if i < 5 else p22 if i < 9 else p23)
|
||||
pool=p21) if i < 3 else p22 if i < 7 else p23)
|
||||
|
||||
p11.current_team = tds[0]
|
||||
p11.save()
|
||||
|
|
Loading…
Reference in New Issue