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

39 statements  

1""" 

2test_cmds.py 

3 

4tests functions in the cmds module 

5""" 

6 

7import pytest 

8import cmds 

9import error 

10import cmessage 

11 

12pytestmark = pytest.mark.anyio 

13 

14async def test_echo(): 

15 """ 

16 tests cmds.echo 

17 """ 

18 

19 # no arguments 

20 with pytest.raises(error.ArgumentRequiredError): 

21 assert await cmds.echo(cmessage.Message()) 

22 

23 # normal usage 

24 assert await cmds.echo(cmessage.Message(), *["Test"]) == "`Tester#1234:` Test" 

25 

26async def test_ping(): 

27 """ 

28 tests cmds.ping 

29 """ 

30 

31 # no arguments 

32 with pytest.raises(error.ArgumentRequiredError): 

33 assert await cmds.ping(cmessage.Message()) 

34 

35 # too many arguments 

36 with pytest.raises(error.UnknownArgumentError): 

37 assert await cmds.ping(cmessage.Message(), *["1", "2"]) 

38 

39 # normal usage 

40 assert await cmds.ping(cmessage.Message(), *["google.com"]) 

41 

42async def test_time(): 

43 """ 

44 tests cmds.time 

45 """ 

46 

47 # no arguments 

48 assert await cmds.time(cmessage.Message()) 

49 

50 # too many arguments 

51 with pytest.raises(error.UnknownArgumentError): 

52 assert await cmds.time(cmessage.Message(), *["1", "2"]) 

53 

54 # unknown timezone 

55 with pytest.raises(error.TimezoneNotFoundError): 

56 assert await cmds.time(cmessage.Message(), *["1"]) 

57 

58 # normal usage 

59 assert await cmds.time(cmessage.Message(), *["America/New_York"]) 

60 

61async def test_ver(): 

62 """ 

63 tests cmds.ver 

64 """ 

65 

66 # no arguments 

67 assert await cmds.ver(cmessage.Message()) 

68 

69 # too many arguments 

70 with pytest.raises(error.UnknownArgumentError): 

71 assert await cmds.ver(cmessage.Message(), *["1"]) 

72 

73async def test_help(): 

74 """ 

75 tests cmds.help 

76 """ 

77 

78 # no arguments 

79 with pytest.raises(FileNotFoundError): 

80 assert await cmds.chelp(cmessage.Message()) 

81 

82 # too many arguments 

83 with pytest.raises(error.UnknownArgumentError): 

84 assert await cmds.chelp(cmessage.Message(), *["1", "2"]) 

85 

86 # unknwon help 

87 with pytest.raises(error.HelpNotFoundError): 

88 assert await cmds.chelp(cmessage.Message(), *["1"]) 

89 

90async def test_invite(): 

91 """ 

92 tests cmds.invite 

93 """ 

94 

95 # no arguments 

96 assert await cmds.invite(cmessage.Message()) 

97 

98 # too many arguments 

99 with pytest.raises(error.UnknownArgumentError): 

100 assert await cmds.invite(cmessage.Message(), *["1", "2"]) 

101 

102 # normal usage 

103 with pytest.raises(FileNotFoundError): 

104 assert await cmds.invite(cmessage.Message(), *["1"])