2014-03-13 16:43:27 +00:00
|
|
|
import pydle
|
2014-03-15 14:55:59 +00:00
|
|
|
|
|
|
|
from pytest import mark
|
2014-03-13 16:43:27 +00:00
|
|
|
from .fixtures import with_client
|
|
|
|
from .mocks import MockClient, MockServer, MockConnection, MockEventLoop
|
|
|
|
|
|
|
|
|
2014-03-15 14:55:59 +00:00
|
|
|
@mark.meta
|
2014-03-13 16:43:27 +00:00
|
|
|
@with_client(connected=False)
|
|
|
|
def test_fixtures_with_client(server, client):
|
|
|
|
assert isinstance(server, MockServer)
|
|
|
|
assert isinstance(client, MockClient)
|
|
|
|
assert client.__class__.__mro__[1] is MockClient, 'MockClient should be first in method resolution order'
|
|
|
|
|
|
|
|
assert not client.connected
|
|
|
|
|
2014-03-15 14:55:59 +00:00
|
|
|
@mark.meta
|
2014-03-13 16:43:27 +00:00
|
|
|
@with_client(pydle.features.RFC1459Support, connected=False)
|
|
|
|
def test_fixtures_with_client_features(server, client):
|
|
|
|
assert isinstance(client, MockClient)
|
|
|
|
assert client.__class__.__mro__[1] is MockClient, 'MockClient should be first in method resolution order'
|
|
|
|
assert isinstance(client, pydle.features.RFC1459Support)
|
|
|
|
|
2014-03-15 14:55:59 +00:00
|
|
|
@mark.meta
|
2014-03-14 23:29:55 +00:00
|
|
|
@with_client(username='test_runner')
|
|
|
|
def test_fixtures_with_client_options(server, client):
|
|
|
|
assert client.username == 'test_runner'
|
|
|
|
|
2014-03-15 14:55:59 +00:00
|
|
|
@mark.meta
|
2014-03-13 16:43:27 +00:00
|
|
|
@with_client()
|
|
|
|
def test_fixtures_with_client_connected(server, client):
|
|
|
|
assert client.connected
|
|
|
|
assert isinstance(client.eventloop, MockEventLoop)
|
|
|
|
assert isinstance(client.connection, MockConnection)
|
|
|
|
assert isinstance(client.connection.eventloop, MockEventLoop)
|
|
|
|
assert client.eventloop is client.connection.eventloop
|