Skip to content

Commit

Permalink
Necromance more Tests
Browse files Browse the repository at this point in the history
Brings us up to 3 failed, 56 passed, 57 warnings (original: 19 failed, 39 passed, 52 warnings)
  • Loading branch information
Rixxan committed Mar 28, 2022
1 parent 896b0d7 commit 493df7f
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 24 deletions.
7 changes: 7 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[pytest]
asyncio_mode = auto
markers =
meta: mark a test as meta
slow: mark a test as sssslllooowwww
ircv3: mark a test as related to v3 of the IRC standard
unit: mark a test as relating to the unit
4 changes: 2 additions & 2 deletions tests/mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def receiveddata(self, data):
return True
return False

def send(self, *args, **kwargs):
async def send(self, *args, **kwargs):
msg = self.connection._mock_client._create_message(*args, **kwargs)
self.connection._mock_client.on_raw(msg)
await self.connection._mock_client.on_raw(msg)

def sendraw(self, data):
self.connection._mock_client.on_data(data)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ async def test_client_server_tag(server, client):

@pytest.mark.asyncio
@with_client()
def test_client_message(server, client):
async def test_client_message(server, client):
client.on_raw_install = Mock()
server.send("INSTALL", "gentoo")
await server.send("INSTALL", "gentoo")
assert client.on_raw_install.called

message = client.on_raw_install.call_args[0][0]
Expand All @@ -153,7 +153,7 @@ def test_client_message(server, client):

@pytest.mark.asyncio
@with_client()
def test_client_unknown(server, client):
async def test_client_unknown(server, client):
client.on_unknown = Mock()
server.send("INSTALL", "gentoo")
await server.send("INSTALL", "gentoo")
assert client.on_unknown.called
4 changes: 2 additions & 2 deletions tests/test_client_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def test_channel_destruction(server, client):

@pytest.mark.asyncio
@with_client()
def test_channel_user_destruction(server, client):
async def test_channel_user_destruction(server, client):
client._create_channel("#pydle")
client._create_user("WiZ")
await client._create_user("WiZ")
client.channels["#pydle"]["users"].add("WiZ")

client._destroy_channel("#pydle")
Expand Down
32 changes: 16 additions & 16 deletions tests/test_client_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ def test_client_same_nick(server, client):

@pytest.mark.asyncio
@with_client()
def test_user_creation(server, client):
client._create_user("WiZ")
async def test_user_creation(server, client):
await client._create_user("WiZ")
assert "WiZ" in client.users
assert client.users["WiZ"]["nickname"] == "WiZ"


@pytest.mark.asyncio
@with_client()
def test_user_invalid_creation(server, client):
client._create_user("irc.fbi.gov")
async def test_user_invalid_creation(server, client):
await client._create_user("irc.fbi.gov")
assert "irc.fbi.gov" not in client.users


@pytest.mark.asyncio
@with_client()
async def test_user_renaming(server, client):
client._create_user("WiZ")
await client._create_user("WiZ")
await client._rename_user("WiZ", "jilles")

assert "WiZ" not in client.users
Expand Down Expand Up @@ -59,7 +59,7 @@ async def test_user_renaming_invalid_creation(server, client):
@pytest.mark.asyncio
@with_client()
async def test_user_renaming_channel_users(server, client):
client._create_user("WiZ")
await client._create_user("WiZ")
client._create_channel("#lobby")
client.channels["#lobby"]["users"].add("WiZ")

Expand All @@ -70,18 +70,18 @@ async def test_user_renaming_channel_users(server, client):

@pytest.mark.asyncio
@with_client()
def test_user_deletion(server, client):
client._create_user("WiZ")
async def test_user_deletion(server, client):
await client._create_user("WiZ")
client._destroy_user("WiZ")

assert "WiZ" not in client.users


@pytest.mark.asyncio
@with_client()
def test_user_channel_deletion(server, client):
async def test_user_channel_deletion(server, client):
client._create_channel("#lobby")
client._create_user("WiZ")
await client._create_user("WiZ")
client.channels["#lobby"]["users"].add("WiZ")

client._destroy_user("WiZ", "#lobby")
Expand All @@ -91,10 +91,10 @@ def test_user_channel_deletion(server, client):

@pytest.mark.asyncio
@with_client()
def test_user_channel_incomplete_deletion(server, client):
async def test_user_channel_incomplete_deletion(server, client):
client._create_channel("#lobby")
client._create_channel("#foo")
client._create_user("WiZ")
await client._create_user("WiZ")
client.channels["#lobby"]["users"].add("WiZ")
client.channels["#foo"]["users"].add("WiZ")

Expand All @@ -106,7 +106,7 @@ def test_user_channel_incomplete_deletion(server, client):
@pytest.mark.asyncio
@with_client()
async def test_user_synchronization(server, client):
client._create_user("WiZ")
await client._create_user("WiZ")
await client._sync_user("WiZ", {"hostname": "og.irc.developer"})

assert client.users["WiZ"]["hostname"] == "og.irc.developer"
Expand All @@ -129,14 +129,14 @@ async def test_user_invalid_synchronization(server, client):
@pytest.mark.asyncio
@with_client()
async def test_user_mask_format(server, client):
client._create_user("WiZ")
await client._create_user("WiZ")
assert client._format_user_mask("WiZ") == "WiZ!*@*"

await client._sync_user("WiZ", {"username": "wiz"})
assert client._format_user_mask("WiZ") == "WiZ!wiz@*"

client._sync_user("WiZ", {"hostname": "og.irc.developer"})
await client._sync_user("WiZ", {"hostname": "og.irc.developer"})
assert client._format_user_mask("WiZ") == "[email protected]"

client._sync_user("WiZ", {"username": None})
await client._sync_user("WiZ", {"username": None})
assert client._format_user_mask("WiZ") == "WiZ!*@og.irc.developer"
14 changes: 14 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
test_misc.py ~ Testing of Misc. Functions
Designed for those simple functions that don't need their own dedicated test files
But we want to hit them anyways
"""
from pydle.protocol import identifierify


async def test_identifierify():
good_name = identifierify("MyVerySimpleName")
bad_name = identifierify("I'mASpec!äl/Name!_")
assert good_name == "myverysimplename"
assert bad_name == "i_maspec__l_name__"

0 comments on commit 493df7f

Please sign in to comment.