Coverage for tests/test_cmds.py: 100%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2test_cmds.py
4tests functions in the cmds module
5"""
7import pytest
8import cmds
9import error
10import cmessage
12pytestmark = pytest.mark.anyio
14async def test_echo():
15 """
16 tests cmds.echo
17 """
19 # no arguments
20 with pytest.raises(error.ArgumentRequiredError):
21 assert await cmds.echo(cmessage.Message())
23 # normal usage
24 assert await cmds.echo(cmessage.Message(), *["Test"]) == "`Tester#1234:` Test"
26async def test_ping():
27 """
28 tests cmds.ping
29 """
31 # no arguments
32 with pytest.raises(error.ArgumentRequiredError):
33 assert await cmds.ping(cmessage.Message())
35 # too many arguments
36 with pytest.raises(error.UnknownArgumentError):
37 assert await cmds.ping(cmessage.Message(), *["1", "2"])
39 # normal usage
40 assert await cmds.ping(cmessage.Message(), *["google.com"])
42async def test_time():
43 """
44 tests cmds.time
45 """
47 # no arguments
48 assert await cmds.time(cmessage.Message())
50 # too many arguments
51 with pytest.raises(error.UnknownArgumentError):
52 assert await cmds.time(cmessage.Message(), *["1", "2"])
54 # unknown timezone
55 with pytest.raises(error.TimezoneNotFoundError):
56 assert await cmds.time(cmessage.Message(), *["1"])
58 # normal usage
59 assert await cmds.time(cmessage.Message(), *["America/New_York"])
61async def test_ver():
62 """
63 tests cmds.ver
64 """
66 # no arguments
67 assert await cmds.ver(cmessage.Message())
69 # too many arguments
70 with pytest.raises(error.UnknownArgumentError):
71 assert await cmds.ver(cmessage.Message(), *["1"])
73async def test_help():
74 """
75 tests cmds.help
76 """
78 # no arguments
79 with pytest.raises(FileNotFoundError):
80 assert await cmds.chelp(cmessage.Message())
82 # too many arguments
83 with pytest.raises(error.UnknownArgumentError):
84 assert await cmds.chelp(cmessage.Message(), *["1", "2"])
86 # unknwon help
87 with pytest.raises(error.HelpNotFoundError):
88 assert await cmds.chelp(cmessage.Message(), *["1"])
90async def test_invite():
91 """
92 tests cmds.invite
93 """
95 # no arguments
96 assert await cmds.invite(cmessage.Message())
98 # too many arguments
99 with pytest.raises(error.UnknownArgumentError):
100 assert await cmds.invite(cmessage.Message(), *["1", "2"])
102 # normal usage
103 with pytest.raises(FileNotFoundError):
104 assert await cmds.invite(cmessage.Message(), *["1"])