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
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', '{') == ['{']
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
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')", )
def test_module(subprocess_mock): aw = AgentWrapper('localhost') dummy = aw.load('dummy') assert dummy.neg(1) == -1
def test_error(subprocess_mock): aw = AgentWrapper('localhost') aw.agent.stdin.write(b'\x00') with pytest.raises(AgentError): aw.test()
def test_bytes(subprocess_mock): aw = AgentWrapper('localhost') assert s2b(aw.test(b2s(b'\x00foo'))[0]) == b'\x00foo'
def test_proxy(subprocess_mock): aw = AgentWrapper('localhost') assert aw.test() == [] assert aw.test(0, 1) == [1, 0]
def test_create(subprocess_mock): aw = AgentWrapper('localhost') aw.close()