def test_link_decorator(): """Test linking the decorator between two methods. """ def testA(): pass def testB(): pass task._decorate(testA, 'foo', 'value') task._link_decorator(testA, testB) assert testA.__garcon__ == testB.__garcon__ assert testA.__garcon__.get('foo') == 'value' assert testB.__garcon__.get('foo') == 'value'
def test_link_decorator_with_empty_source(): """Test linking decorators when garcon is not set on the source. """ def testA(): pass def testB(): pass task._link_decorator(testA, testB) assert not getattr(testA, '__garcon__', None) assert len(testB.__garcon__) is 0 task._decorate(testB, 'foo', 'value') assert testB.__garcon__.get('foo') == 'value'
def test_decorator(): """Test the Decorator. It should add __garcon__ to the method and if a key / value is passed, it should add it. """ def test(): pass task._decorate(test) assert hasattr(test, '__garcon__') task._decorate(test, 'foo') assert test.__garcon__.get('foo') is None task._decorate(test, 'foo', 'bar') assert test.__garcon__.get('foo') is 'bar'