diff --git a/src/endstone_test/tests/on_player_join/test_player.py b/src/endstone_test/tests/on_player_join/test_player.py index 3beaf71..064b3cd 100644 --- a/src/endstone_test/tests/on_player_join/test_player.py +++ b/src/endstone_test/tests/on_player_join/test_player.py @@ -84,10 +84,28 @@ def test_player_scoreboard(player: Player, server: Server): assert player.scoreboard is server.scoreboard -def test_player_tags(player: Player, server: Server): +def test_player_get_tags(player: Player, server: Server): server.dispatch_command(server.command_sender, f'tag "{player.name}" add test_tag') assert "test_tag" in player.scoreboard_tags server.dispatch_command( server.command_sender, f'tag "{player.name}" remove test_tag' ) assert "test_tag" not in player.scoreboard_tags + + +def test_player_add_tag(player: Player, server: Server): + assert player.add_scoreboard_tag("test_tag") + assert "test_tag" in player.scoreboard_tags + + assert not player.add_scoreboard_tag("test_tag") + server.dispatch_command(server.command_sender, f'tag "{player.name}" remove test_tag') + + +def test_player_remove_tag(player: Player, server: Server): + server.dispatch_command(server.command_sender, f'tag "{player.name}" add test_tag') + assert "test_tag" in player.scoreboard_tags + + assert player.remove_scoreboard_tag("test_tag") + assert "test_tag" not in player.scoreboard_tags + + assert not player.remove_scoreboard_tag("test_tag") 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 bb7b396..3633ecf 100644 --- a/src/endstone_test/tests/on_player_join/test_scoreboard.py +++ b/src/endstone_test/tests/on_player_join/test_scoreboard.py @@ -13,32 +13,8 @@ def scoreboard(server: Server) -> Scoreboard: return server.scoreboard -@pytest.fixture(scope="function", autouse=True) -def before_each_after_each(server: Server, scoreboard: Scoreboard): - # Before each test run - 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 - 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 - - def test_scoreboard_value( - player: Player, server: Server, scoreboard: Scoreboard + player: Player, server: Server, scoreboard: Scoreboard ) -> None: server.dispatch_command( server.command_sender, "scoreboard objectives add test_objective dummy" @@ -52,3 +28,7 @@ def test_scoreboard_value( score = objective.get_score(player) assert score.is_score_set assert score.value == 3 + + server.dispatch_command( + server.command_sender, "scoreboard objectives remove test_objective" + )