File: test__fixtures.py

package info (click to toggle)
pydle 0.9.4-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 456 kB
  • sloc: python: 3,037; makefile: 3
file content (36 lines) | stat: -rw-r--r-- 1,301 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pydle

from pytest import mark
from .fixtures import with_client
from .mocks import MockClient, MockServer, MockConnection, MockEventLoop


@mark.meta
@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

@mark.meta
@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)

@mark.meta
@with_client(username='test_runner')
def test_fixtures_with_client_options(server, client):
    assert client.username == 'test_runner'

@mark.meta
@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