Пример #1
0
 def test_lambda(self):
     activation = invoke(
         composer.function(lambda env, args: args['n'] % 2 == 0), {'n': 4})
     assert activation['response']['result'] == {'value': True}
Пример #2
0
 def test_function_true(self):
     activation = invoke(composer.function(isEven), {'n': 4})
     assert activation['response']['result'] == {'value': True}
Пример #3
0
def rands(env, params):
    value = randint(0, 100)
    print(value)
    return {"value": value}


def prob(env, params):
    return {'prob': params['value'] > 70}


def printTrue(env, params):
    print("Results were true")
    return {'result': params['prob']}


def printFalse(env, params):
    print("Results were False")
    return {'result': params['prob']}


composer.composition(
    'getRands',
    composer.sequence(composer.function(rands), composer.function(prob)))
composer.composition('test',
                     composer.when('getRands', 'printTrue', 'printFalse'))


def main():
    return composer.when('getRands', 'printTrue', 'printFalse')
 def test_number_invalid(self):
     try:
         composer.function(42)
     except composer.ComposerError as error:
         assert error.message.startswith('Invalid argument')
 def test_string(self):
     composer.function('lambda : {}')
 def test_function(self):
     composer.function(lambda: {})