from __future__ import annotations import pytest from yuxi.channel.domain.model.binding.channel_binding import ChannelBinding class TestChannelBinding: def test_basic_creation(self): binding = ChannelBinding( id=1, channel_type="web", account_id="user1", group_id="", agent_config_id=1, ) assert binding.id == 1 assert binding.channel_type == "web" assert binding.account_id == "user1" assert binding.group_id == "" assert binding.agent_config_id == 1 def test_creation_with_optional_fields(self): binding = ChannelBinding( id=1, channel_type="web", account_id="user1", group_id="group1", agent_config_id=1, session_key_strategy="main", ) assert binding.group_id == "group1" assert binding.session_key_strategy == "main" def test_to_dict(self): binding = ChannelBinding( id=1, channel_type="web", account_id="user1", group_id="", agent_config_id=1, ) d = binding.to_dict() assert d["id"] == 1 assert d["channel_type"] == "web" assert d["account_id"] == "user1" assert d["agent_config_id"] == 1 def test_from_dict(self): d = { "id": 1, "channel_type": "web", "account_id": "user1", "group_id": "", "agent_config_id": 1, } binding = ChannelBinding.from_dict(d) assert binding.id == 1 assert binding.channel_type == "web" assert binding.account_id == "user1" def test_default_values(self): binding = ChannelBinding( id=1, channel_type="web", account_id="user1", group_id="", agent_config_id=1, ) assert binding.session_key_strategy is None