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

5 years ago
  1. """
  2. file: test_server.py
  3. adds server functionality-tests for pytest
  4. date: 11.07.2019
  5. """
  6. import pytest
  7. def test_ping(server):
  8. assert server.ping(server, "tolsun.oulu.fi") == "PONG"
  9. @pytest.mark.parametrize("test_input,expected", [("password", True), ("wrong password", False)])
  10. def test_command_pass(server, test_input, expected):
  11. server.password = "password"
  12. assert server.command_pass(server, test_input) == expected
  13. def create_user_list():
  14. user_list = list()
  15. user_id = "user"
  16. for i in range(0, 9):
  17. user_list.append((user_id + str(i)))
  18. return user_list
  19. @pytest.mark.parametrize("user_list, nickname, expected_result",
  20. [
  21. (create_user_list(), "wayne", True),
  22. (create_user_list(), "user2", False),
  23. (create_user_list(), "christoph", True),
  24. (create_user_list(), "user19", True)])
  25. def test_change_nickname(server, user_list, nickname, expected_result):
  26. server.user_list = create_user_list()
  27. assert server.command_nickname(server, nickname) == expected_result