Decorators used throughout Firmant.
Assert that key is in the environment.
>>> @in_environment('somekey')
... def testfunc(environment):
... print 'testfunc executes'
...
>>> inspect.getargspec(testfunc)
ArgSpec(args=['environment'], varargs=None, keywords=None, defaults=None)
>>> testfunc({'somekey': True})
testfunc executes
>>> testfunc(environment={'somekey': True})
testfunc executes
>>> testfunc({})
Traceback (most recent call last):
ValueError: Expected 'somekey' in 'environment'
The decorated function must take a non-keyword attribute for the environment.
>>> @in_environment('somekey')
... def testfunc():
... print 'testfunc executes'
...
Traceback (most recent call last):
AttributeError: Decorated function must have arg 'environment'
Environment cannot have a default value.
>>> @in_environment('somekey')
... def testfunc(environment=None):
... print 'testfunc executes'
...
Traceback (most recent call last):
AttributeError: Decorated function cannot have default value for 'environment'