MCPcopy Index your code
hub / github.com/coleifer/huey / test_group_callback

Method test_group_callback

huey/tests/test_api.py:1477–1502  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1475 self.assertEqual(r(), ['low', 'high', 'mid'])
1476
1477 def test_group_callback(self):
1478 @self.huey.task()
1479 def ident(v):
1480 return v
1481
1482 g = group([ident.s('a'), ident.s('b')]).then(ident)
1483 r = self.huey.enqueue(g)
1484 self.assertEqual(len(self.huey), 2)
1485 self.execute_next()
1486 self.execute_next()
1487 self.assertEqual(len(self.huey), 1)
1488 self.assertEqual(self.execute_next(), ['a', 'b'])
1489
1490 # When groups have a callback they are converted to chord.
1491 g = group([
1492 ident.s('a', priority=1),
1493 ident.s('b', priority=10),
1494 ident.s('c', priority=5)]).then(ident)
1495 r = self.huey.enqueue(g)
1496 self.assertEqual(len(self.huey), 3)
1497 self.assertEqual(self.execute_next(), 'b')
1498 self.assertEqual(self.execute_next(), 'c')
1499 self.assertEqual(self.execute_next(), 'a')
1500 self.assertEqual(len(self.huey), 1)
1501 self.assertEqual(self.execute_next(), ['a', 'b', 'c'])
1502 self.assertEqual(r(), ['a', 'b', 'c'])
1503
1504 def test_group_error_handler(self):
1505 error_state = []

Callers

nothing calls this directly

Calls 5

groupClass · 0.90
sMethod · 0.80
execute_nextMethod · 0.80
thenMethod · 0.45
enqueueMethod · 0.45

Tested by

no test coverage detected