Example #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
Example #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
Example #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
Example #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
Example #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 == ([],)
Example #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
Example #7
0
 def test_init(self):
     f = Mock()
     chute = Chute.create(f)()
     assert not f.called
     assert len(chute.callbacks) is 0
Example #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)
Example #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
Example #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
Example #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
Example #12
0
 def test_callbacks(self):
     f = Mock()
     chute = Chute.create(f)()
     assert chute.callbacks == []
     chute.callbacks.append("foo")
     assert "foo" in chute.callbacks