|
|
@ -1,5 +1,9 @@ |
|
|
|
""" |
|
|
|
tests the server functionality |
|
|
|
file: test_server.py |
|
|
|
|
|
|
|
adds server functionality-tests for pytest |
|
|
|
|
|
|
|
date: 11.07.2019 |
|
|
|
""" |
|
|
|
import pytest |
|
|
|
|
|
|
@ -12,3 +16,23 @@ def test_ping(server): |
|
|
|
def test_command_pass(server, test_input, expected): |
|
|
|
server.password = "password" |
|
|
|
assert server.command_pass(server, test_input) == expected |
|
|
|
|
|
|
|
|
|
|
|
def create_user_list(): |
|
|
|
user_list = list() |
|
|
|
user_id = "user" |
|
|
|
for i in range(0, 9): |
|
|
|
user_list.append((user_id + str(i))) |
|
|
|
|
|
|
|
return user_list |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("user_list, 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): |
|
|
|
server.user_list = create_user_list() |
|
|
|
assert server.command_nickname(server, nickname) == expected_result |