Exemplo n.º 1
0
 def test_call(self):
     f = Mock()
     f2 = Mock()
     chute = Chute.create(f)()
     chute.to(Chute.create(f2)())
     chute()
     assert f.called
     assert f2.called
Exemplo n.º 2
0
 def test_compose(self):
     noop = lambda x: x
     foo = Chute.create(noop)()
     bar = Chute.create(noop)()
     Composite = Hellbox.compose(foo, bar)
     composed = Composite()
     assert composed.head is foo
     assert composed.tail is bar
     assert bar in foo.callbacks
Exemplo n.º 3
0
 def test_composite_chute(self):
     noop = lambda x: x
     foo = Chute.create(noop)()
     bar = Chute.create(noop)()
     baz = Chute.create(noop)()
     qux = Chute.create(noop)()
     composite = CompositeChute(foo, bar)
     composite >> baz
     qux >> composite
     assert baz in composite.tail.callbacks
     assert composite.head in qux.callbacks
Exemplo n.º 4
0
 def test_run_task_with_requirements(self):
     f = Mock()
     f2 = Mock()
     task = Task('fooqaaz')
     task.requires('foobar')
     task.start_chain(Chute.create(f)())
     task2 = Task('foobar')
     task2.start_chain(Chute.create(f2)())
     Hellbox.add_task(task)
     Hellbox.add_task(task2)
     Hellbox.run_task('fooqaaz')
     assert f2.called
Exemplo n.º 5
0
 def test_run(self):
     f = Mock()
     task = Task('foo')
     task.start_chain(Chute.create(f)())
     task.run()
     assert f.called
     assert f.args == ([],)
Exemplo n.º 6
0
 def test_run_task(self):
     f = Mock()
     task = Task('foobaz')
     task.start_chain(Chute.create(f)())
     Hellbox.add_task(task)
     Hellbox.run_task('foobaz')
     assert f.called
Exemplo n.º 7
0
 def test_init(self):
     f = Mock()
     chute = Chute.create(f)()
     assert not f.called
     assert len(chute.callbacks) is 0
Exemplo n.º 8
0
 def test_to_with_unintialized_chute(self):
     chute = Chute.create(Mock())()
     cb = Chute.create(Mock())
     chute.to(cb)
     assert chute.callbacks
     assert isinstance(chute.callbacks[0], cb)
Exemplo n.º 9
0
 def test_lshift(self):
     chute = Chute.create(Mock())()
     cb = Chute.create(Mock())()
     result = cb << chute
     assert result is chute
     assert cb in chute.callbacks
Exemplo n.º 10
0
 def test_rshift(self):
     chute = Chute.create(Mock())()
     cb = Chute.create(Mock())()
     result = chute >> cb
     assert result is cb
     assert cb in chute.callbacks
Exemplo n.º 11
0
 def test_to(self):
     chute = Chute.create(Mock())()
     cb = Chute.create(Mock())()
     result = chute.to(cb)
     assert result is cb
     assert cb in chute.callbacks
Exemplo n.º 12
0
 def test_callbacks(self):
     f = Mock()
     chute = Chute.create(f)()
     assert chute.callbacks == []
     chute.callbacks.append("foo")
     assert "foo" in chute.callbacks