|
|
"""
file: test_server.py
adds server functionality-tests for pytest
date: 11.07.2019 """
import pytest
def test_ping(server): assert server.ping(server, "tolsun.oulu.fi") == "PONG"
@pytest.mark.parametrize("test_input,expected", [("password", True), ("wrong password", False)]) 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
|