Some checks failed
CI / test-backend (pull_request) Successful in 4s
CI / test-backend (push) Successful in 24s
Build and Publish Docker Image / build (pull_request) Has been skipped
CI / lint (pull_request) Failing after 2m35s
CI / lint (push) Failing after 2m43s
OSV-Scanner PR Scan / scan-pr (pull_request) Successful in 52s
CI / build-frontend (push) Successful in 9m42s
CI / test-lang (push) Successful in 9m40s
CI / test-lang (pull_request) Successful in 9m33s
CI / build-frontend (pull_request) Successful in 9m47s
Build Test / Build and Test (pull_request) Successful in 15m55s
Build Test / Build and Test (push) Successful in 16m1s
Build and Publish Docker Image / build-dev (pull_request) Successful in 17m17s
Tests / test (push) Failing after 18m50s
Tests / test (pull_request) Successful in 16m55s
93 lines
2.8 KiB
Python
93 lines
2.8 KiB
Python
import os
|
|
import tempfile
|
|
|
|
import pytest
|
|
|
|
from meshchatx.src.backend.config_manager import ConfigManager
|
|
from meshchatx.src.backend.database import Database
|
|
|
|
|
|
@pytest.fixture
|
|
def db():
|
|
fd, path = tempfile.mkstemp()
|
|
os.close(fd)
|
|
database = Database(path)
|
|
database.initialize()
|
|
yield database
|
|
database.close()
|
|
if os.path.exists(path):
|
|
os.remove(path)
|
|
|
|
|
|
def test_config_manager_get_default(db):
|
|
config = ConfigManager(db)
|
|
assert config.display_name.get() == "Anonymous Peer"
|
|
assert config.theme.get() == "light"
|
|
assert config.lxmf_inbound_stamp_cost.get() == 8
|
|
|
|
|
|
def test_config_manager_set_get(db):
|
|
config = ConfigManager(db)
|
|
config.display_name.set("Test User")
|
|
assert config.display_name.get() == "Test User"
|
|
|
|
config.lxmf_inbound_stamp_cost.set(20)
|
|
assert config.lxmf_inbound_stamp_cost.get() == 20
|
|
|
|
config.auto_announce_enabled.set(True)
|
|
assert config.auto_announce_enabled.get() is True
|
|
|
|
|
|
def test_config_manager_persistence(db):
|
|
config = ConfigManager(db)
|
|
config.display_name.set("Persistent User")
|
|
|
|
# New manager instance with same DB
|
|
config2 = ConfigManager(db)
|
|
assert config2.display_name.get() == "Persistent User"
|
|
|
|
|
|
def test_config_manager_type_safety(db):
|
|
config = ConfigManager(db)
|
|
|
|
# IntConfig
|
|
config.lxmf_inbound_stamp_cost.set(
|
|
"15",
|
|
) # Should handle string to int if implementation allows or just store it
|
|
# Looking at implementation might be better, but let's test basic set/get
|
|
config.lxmf_inbound_stamp_cost.set(15)
|
|
assert isinstance(config.lxmf_inbound_stamp_cost.get(), int)
|
|
assert config.lxmf_inbound_stamp_cost.get() == 15
|
|
|
|
# BoolConfig
|
|
config.auto_announce_enabled.set(True)
|
|
assert config.auto_announce_enabled.get() is True
|
|
config.auto_announce_enabled.set(False)
|
|
assert config.auto_announce_enabled.get() is False
|
|
|
|
|
|
def test_telephony_config(db):
|
|
config = ConfigManager(db)
|
|
|
|
# Test DND
|
|
assert config.do_not_disturb_enabled.get() is False
|
|
config.do_not_disturb_enabled.set(True)
|
|
assert config.do_not_disturb_enabled.get() is True
|
|
|
|
# Test Contacts Only
|
|
assert config.telephone_allow_calls_from_contacts_only.get() is False
|
|
config.telephone_allow_calls_from_contacts_only.set(True)
|
|
assert config.telephone_allow_calls_from_contacts_only.get() is True
|
|
|
|
# Test Call Recording
|
|
assert config.call_recording_enabled.get() is False
|
|
config.call_recording_enabled.set(True)
|
|
assert config.call_recording_enabled.get() is True
|
|
|
|
|
|
def test_auto_propagation_config(db):
|
|
config = ConfigManager(db)
|
|
assert config.lxmf_preferred_propagation_node_auto_select.get() is False
|
|
config.lxmf_preferred_propagation_node_auto_select.set(True)
|
|
assert config.lxmf_preferred_propagation_node_auto_select.get() is True
|