Esempio n. 1
0
def test_all_modules():
    aw = AgentWrapper(None)
    aw.load('deditec_relais8')
    methods = aw.list()
    assert 'deditec_relais8.set' in methods
    assert 'deditec_relais8.get' in methods
    aw.load('sysfsgpio')
    methods = aw.list()
    assert 'sysfsgpio.set' in methods
    assert 'sysfsgpio.get' in methods
Esempio n. 2
0
def test_call(subprocess_mock):
    aw = AgentWrapper('localhost')
    assert aw.call('test') == []
    assert aw.call('test', 0) == [0]
    assert aw.call('test', 0, 1) == [1, 0]
    assert aw.call('test', 'foo') == ['foo']
    assert aw.call('test', '{') == ['{']
Esempio n. 3
0
def test_local():
    aw = AgentWrapper(None)

    assert aw.test() == []
    assert aw.test(0, 1) == [1, 0]

    assert s2b(aw.test(b2s(b'\x00foo'))[0]) == b'\x00foo'

    with pytest.raises(AgentException) as excinfo:
        aw.error('foo')
    assert excinfo.value.args == ("ValueError('foo')", )

    with pytest.raises(AgentException) as excinfo:
        aw.error('bar')
    assert excinfo.value.args == ("ValueError('bar')", )

    dummy = aw.load('dummy')
    assert dummy.neg(1) == -1
Esempio n. 4
0
def test_exception(subprocess_mock):
    aw = AgentWrapper('localhost')

    with pytest.raises(AgentException) as excinfo:
        aw.error('foo')
    assert excinfo.value.args == ("ValueError('foo')", )

    with pytest.raises(AgentException) as excinfo:
        aw.error('bar')
    assert excinfo.value.args == ("ValueError('bar')", )
Esempio n. 5
0
def test_module(subprocess_mock):
    aw = AgentWrapper('localhost')
    dummy = aw.load('dummy')
    assert dummy.neg(1) == -1
Esempio n. 6
0
def test_error(subprocess_mock):
    aw = AgentWrapper('localhost')
    aw.agent.stdin.write(b'\x00')
    with pytest.raises(AgentError):
        aw.test()
Esempio n. 7
0
def test_bytes(subprocess_mock):
    aw = AgentWrapper('localhost')
    assert s2b(aw.test(b2s(b'\x00foo'))[0]) == b'\x00foo'
Esempio n. 8
0
def test_proxy(subprocess_mock):
    aw = AgentWrapper('localhost')
    assert aw.test() == []
    assert aw.test(0, 1) == [1, 0]
Esempio n. 9
0
def test_create(subprocess_mock):
    aw = AgentWrapper('localhost')
    aw.close()