コード例 #1
0
ファイル: test_storage.py プロジェクト: IoTtalk/iottalk-core
def test_function_add_duplicate(_func):
    src = (
        'def run():\n'
        '    pass'
    )
    key = sha256(src.encode('utf-8')).hexdigest()

    assert UserFunction.add(key, src)
    assert UserFunction.select(key) == src

    assert UserFunction.add(key, src) is False
コード例 #2
0
ファイル: test_storage.py プロジェクト: IoTtalk/iottalk-core
def test_function_add_key_mismatch(_func):
    src = (
        'def run():\n'
        '    pass'
    )

    with pytest.raises(ValueError) as err:
        assert UserFunction.add('42', src)

    assert UserFunction.select() == {}
    assert 'mismatched' in str(err)
コード例 #3
0
ファイル: test_storage.py プロジェクト: IoTtalk/iottalk-core
def test_function_rm(_func):
    src = (
        'def run():\n'
        '    pass'
    )
    key = sha256(src.encode('utf-8')).hexdigest()

    assert UserFunction.add(key, src)
    assert UserFunction.select(key) == src

    assert UserFunction.rm(key)
    assert UserFunction.select() == {}