From 9521ee0aed3022c396422c96f852c1b279ae4a24 Mon Sep 17 00:00:00 2001 From: Wayne Colin Abel Date: Tue, 16 Jul 2019 12:25:43 +0200 Subject: [PATCH] =?UTF-8?q?[refactor]=20teststruktur=20verbessert,=20komme?= =?UTF-8?q?ntare=20angef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_server.py | 61 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/test/test_server.py b/test/test_server.py index 76343a5..2726049 100644 --- a/test/test_server.py +++ b/test/test_server.py @@ -14,6 +14,27 @@ def test_ping(server): @pytest.mark.parametrize("test_input,expected", [("password", True), ("wrong password", False)]) def test_command_pass(server, test_input, expected): + """ + Command: PASS + Parameters: + + The PASS command is used to set a 'connection password'. The + password can and must be set before any attempt to register the + connection is made. Currently this requires that clients send a PASS + command before sending the NICK/USER combination and servers *must* + send a PASS command before any SERVER command. The password supplied + must match the one contained in the C/N lines (for servers) or I + lines (for clients). It is possible to send multiple PASS commands + before registering but only the last one sent is used for + verification and it may not be changed once registered. Numeric + Replies: + + ERR_NEEDMOREPARAMS ERR_ALREADYREGISTRED + + Example: + + PASS secretpasswordhere + """ server.password = "password" assert server.command_pass(server, test_input) == expected @@ -27,12 +48,38 @@ def create_user_list(): return user_list -@pytest.mark.parametrize("user_list, nickname, expected_result", +@pytest.mark.parametrize("user_list, user_to_change, nickname, expected_result", [ - (create_user_list(), "wayne", True), - (create_user_list(), "user2", False), - (create_user_list(), "christoph", True), - (create_user_list(), "user19", True)]) -def test_change_nickname(server, user_list, nickname, expected_result): + (create_user_list(), "user2", "wayne", True), + (create_user_list(), "user2", "user4", True), + (create_user_list(), "user2", "christoph", True), + (create_user_list(), "user2", "user19", True)]) +def test_change_nickname(server, user_list,user_to_change, nickname, expected_result): + """ + Command: NICK + Parameters: [ ] + + NICK message is used to give user a nickname or change the previous + one. The parameter is only used by servers to indicate + how far away a nick is from its home server. A local connection has + a hopcount of 0. If supplied by a client, it must be ignored. + + If a NICK message arrives at a server which already knows about an + identical nickname for another client, a nickname collision occurs. + As a result of a nickname collision, all instances of the nickname + are removed from the server's database, and a KILL command is issued + to remove the nickname from all other server's database. If the NICK + message causing the collision was a nickname change, then the + original (old) nick must be removed as well. + + If the server recieves an identical NICK from a client which is + directly connected, it may issue an ERR_NICKCOLLISION to the local + client, drop the NICK command, and not generate any kills. + """ server.user_list = create_user_list() - assert server.command_nickname(server, nickname) == expected_result + assert server.command_nickname(server, user_to_change, nickname) == expected_result + assert user_to_change not in server.user_list + if nickname not in user_list: + assert nickname in server.user_list + else: + assert nickname not in server.user_list