Exemplo n.º 1
0
def test_init():
    base = Lambda()

    lib_path_name = os.path.dirname(os.path.realpath(__file__))
    p = re.compile('tests/Lambda')
    assert p.sub('AwAws/Lambda/lib', lib_path_name) in sys.path
    assert '/var/task/lib' in sys.path
    assert base.status == 'ok'
Exemplo n.º 2
0
def test_get_handler():
    function = Lambda.get_handler()
    assert function.__name__ == 'handler'
    assert function('whipit', None) == 'whipped'

    # if we call this function here we are going to error out
    # this is intentional as we should not be running handle from here,
    # in needs to be implemented in a class
    with pytest.raises(NotImplementedError):
        assert function([], None).__name__ == 'something'
Exemplo n.º 3
0
def test_handle():
    with pytest.raises(NotImplementedError):
        base = Lambda()
        base.handle(None, None)
Exemplo n.º 4
0
def test_get_env():
    os.environ['AW_OTHER'] = 'other_env_variable'
    base = Lambda()
    assert base.get_env('AW_OTHER') == 'other_env_variable'
    os.environ.pop('AW_OTHER')
Exemplo n.º 5
0
def test_get_aw_account():
    os.environ['AW_ACCT'] = 'test_account'
    base = Lambda()
    assert base.get_aw_account() == 'test_account'
    os.environ.pop('AW_ACCT')
Exemplo n.º 6
0
def test_get_aw_env():
    os.environ['AW_ENV'] = 'test_environment'
    base = Lambda()
    assert base.get_aw_env() == 'test_environment'
    os.environ.pop('AW_ENV')
Exemplo n.º 7
0
def test_get_region():
    os.environ['AWS_REGION'] = 'us-4-least'
    base = Lambda()
    assert base.get_region() == 'us-4-least'
    os.environ.pop('AWS_REGION')
Exemplo n.º 8
0
def test_do_something():
    base = Lambda()
    assert base.do_something() == 'ok'