update travis and appveyor configs

update travis and appveyor configs to run pytest instead of nosetests
This commit is contained in:
Brian Martin 2019-06-03 09:55:22 -04:00
parent 615c6011ed
commit bcafa83c65
4 changed files with 34 additions and 4 deletions

View file

@ -16,7 +16,7 @@ def mock_transport_extra_info(*args, **kwargs):
return ("127.0.0.1", 1234)
async def test_client(*args, **kwargs):
async def test_client_init(*args, **kwargs):
test_transport = asyncio.Transport()
test_transport.get_extra_info = mock.Mock(return_value=mock_transport_extra_info())
test_transport.write = mock.Mock(return_value=return_send_data)
@ -46,3 +46,34 @@ async def test_client(*args, **kwargs):
# Reset mock calls
mock_send.reset_mock()
async def test_bot_init(*args, **kwargs):
test_transport = asyncio.Transport()
test_transport.get_extra_info = mock.Mock(return_value=mock_transport_extra_info())
test_transport.write = mock.Mock(return_value=return_send_data)
xmppclient = bumper.xmppserver.XMPPAsyncClient(test_transport)
xmppclient.state = xmppclient.INIT # Set client state to INIT
mock_send = xmppclient.send = mock.Mock(side_effect=return_send_data)
# Send init connect stream from "client"
test_data = "<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='159.ecorobot.net' version='1.0'>".encode(
"utf-8"
)
xmppclient._parse_data(test_data)
# Expect 2 calls to send
assert mock_send.call_count == 2
# Server opens stream
assert (
mock_send.mock_calls[0].args[0]
== '<stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" version="1.0" id="1" from="ecouser.net">'
)
# Server tells client available features
assert (
mock_send.mock_calls[1].args[0]
== '<stream:features><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></stream:features>'
)
# Reset mock calls
mock_send.reset_mock()