29 lines
No EOL
791 B
Python
29 lines
No EOL
791 B
Python
import pytest
|
|
from pathlib import Path
|
|
from state_manager import StateManager
|
|
import json
|
|
|
|
@pytest.fixture
|
|
def state_file(tmp_path):
|
|
return tmp_path / "state.json"
|
|
|
|
@pytest.fixture
|
|
def state_manager(state_file):
|
|
return StateManager(state_file)
|
|
|
|
def test_load_state_default(state_manager):
|
|
state = state_manager.load_state()
|
|
assert state == {"autopilot": False}
|
|
|
|
def test_save_state(state_manager):
|
|
state = {"autopilot": True}
|
|
state_manager.save_state(state)
|
|
loaded_state = state_manager.load_state()
|
|
assert loaded_state == state
|
|
|
|
def test_set_autopilot(state_manager):
|
|
state_manager.set_autopilot(True)
|
|
assert state_manager.is_autopilot_enabled() is True
|
|
|
|
state_manager.set_autopilot(False)
|
|
assert state_manager.is_autopilot_enabled() is False |