import dataclasses
import socket
from unittest import TestCase

from ha_services.mqtt4homeassistant.data_classes import MqttSettings
from ha_services.mqtt4homeassistant.utilities.string_utils import slugify


class DataClassesTestCase(TestCase):
    def test_mqtt_settings(self):
        with self.assertLogs():
            mqtt_settings = MqttSettings()
        self.assertEqual(
            dataclasses.asdict(mqtt_settings),
            {
                'host': 'mqtt.eclipseprojects.io',
                'port': 1883,
                'password': '',
                'user_name': '',
                'main_uid': slugify(socket.gethostname(), sep='_'),
            },
        )
