from netbox_unifi_sync.services.sync.netbox_orm import _Endpoint


class IPRange:
    def __init__(self, **kwargs):
        self.saved = False
        for key, value in kwargs.items():
            setattr(self, key, value)

    def save(self):
        self.saved = True


def test_iprange_endpoint_strips_masks_from_host_endpoints():
    endpoint = _Endpoint(IPRange)

    translated = endpoint._translate_kwargs({
        "start_address": "10.88.0.50/24",
        "end_address": "10.88.0.200/24",
    })
    assert translated["start_address"] == "10.88.0.50"
    assert translated["end_address"] == "10.88.0.200"

    created = endpoint.create({
        "start_address": "10.88.0.50/24",
        "end_address": "10.88.0.200/24",
        "description": "UniFi DHCP: LAN",
    })
    assert created.start_address == "10.88.0.50"
    assert created.end_address == "10.88.0.200"
