You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
"""
|
|
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
|