Example #1
0
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
Example #2
0
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)
Example #3
0
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() == {}