diff --git a/src/endstone_test/tests/on_load/test_server.py b/src/endstone_test/tests/on_load/test_server.py index 65f0ab4..4fbcc28 100644 --- a/src/endstone_test/tests/on_load/test_server.py +++ b/src/endstone_test/tests/on_load/test_server.py @@ -1,4 +1,5 @@ import time +from pathlib import Path import pytest from endstone import Server, Translatable, __minecraft_version__ @@ -32,3 +33,15 @@ def test_max_players(server: Server) -> None: # set max players server.max_players = 100 assert server.max_players == 100 + + +def test_online_mode(plugin: Plugin, server: Server) -> None: + properties_file = Path(plugin.data_folder, "..", "..", "server.properties") + with properties_file.open(mode='r') as file: + for line in file: + if line.startswith('online-mode='): + value = line.split('=', 1)[1].strip() + assert (value.lower() == 'true') == server.online_mode + return + + assert False diff --git a/src/endstone_test/tests/on_player_join/test_scoreboard.py b/src/endstone_test/tests/on_player_join/test_scoreboard.py index da98737..8b66476 100644 --- a/src/endstone_test/tests/on_player_join/test_scoreboard.py +++ b/src/endstone_test/tests/on_player_join/test_scoreboard.py @@ -16,14 +16,19 @@ def scoreboard(server: Server) -> Scoreboard: @pytest.fixture(scope="function", autouse=True) def before_each_after_each(server: Server, scoreboard: Scoreboard): # Before each test run - server.dispatch_command(server.command_sender, "scoreboard objectives remove test_objective") + objective = scoreboard.get_objective("test_objective") + if objective is not None: + server.dispatch_command(server.command_sender, "scoreboard objectives remove test_objective") + objective = scoreboard.get_objective("test_objective") assert objective is None yield # After each test run - server.dispatch_command(server.command_sender, "scoreboard objectives remove test_objective") + objective = scoreboard.get_objective("test_objective") + if objective is not None: + server.dispatch_command(server.command_sender, "scoreboard objectives remove test_objective") objective = scoreboard.get_objective("test_objective") assert objective is None