# Path: notifications_utils/international_billing_rates.py
# COUNTRY_PREFIXES = list(reversed(sorted(INTERNATIONAL_BILLING_RATES.keys(), key=len)))
# 
# INTERNATIONAL_BILLING_RATES = yaml.safe_load(f)
# 
# Path: notifications_utils/recipients.py
# def use_numeric_sender(number):
#     prefix = get_international_prefix(normalise_phone_number(number))
#     return INTERNATIONAL_BILLING_RATES[prefix]['attributes']['alpha'] == 'NO'


import pytest
from notifications_utils.international_billing_rates import (
    COUNTRY_PREFIXES,
    INTERNATIONAL_BILLING_RATES,
)
from notifications_utils.recipients import use_numeric_sender



def test_international_billing_rates_exists():
    assert INTERNATIONAL_BILLING_RATES['1']['names'][0] == 'Canada'


@pytest.mark.parametrize('country_prefix, values', sorted(INTERNATIONAL_BILLING_RATES.items()))
def test_international_billing_rates_are_in_correct_format(country_prefix, values):
    assert isinstance(country_prefix, str)
    # we don't want the prefixes to have + at the beginning for instance
    assert country_prefix.isdigit()

    assert set(values.keys()) == {'attributes', 'billable_units', 'names'}

    assert isinstance(values['billable_units'], int)
    assert 1 <= values['billable_units'] <= 3

    assert isinstance(values['names'], list)
    assert all(isinstance(country, str) for country in values['names'])

    assert isinstance(values['attributes'], dict)
    assert values['attributes']['dlr'] is None or isinstance(values['attributes']['dlr'], str)


def test_country_codes():

# Path: notifications_utils/international_billing_rates.py
# COUNTRY_PREFIXES = list(reversed(sorted(INTERNATIONAL_BILLING_RATES.keys(), key=len)))
# 
# INTERNATIONAL_BILLING_RATES = yaml.safe_load(f)
# 
# Path: notifications_utils/recipients.py
# def use_numeric_sender(number):
#     prefix = get_international_prefix(normalise_phone_number(number))
#     return INTERNATIONAL_BILLING_RATES[prefix]['attributes']['alpha'] == 'NO'


# Path: tests/test_international_billing_rates.py
import pytest
from notifications_utils.international_billing_rates import (
    COUNTRY_PREFIXES,
    INTERNATIONAL_BILLING_RATES,
)
from notifications_utils.recipients import use_numeric_sender




def test_international_billing_rates_exists():
    assert INTERNATIONAL_BILLING_RATES['1']['names'][0] == 'Canada'


@pytest.mark.parametrize('country_prefix, values', sorted(INTERNATIONAL_BILLING_RATES.items()))
def test_international_billing_rates_are_in_correct_format(country_prefix, values):
    assert isinstance(country_prefix, str)
    # we don't want the prefixes to have + at the beginning for instance
    assert country_prefix.isdigit()

    assert set(values.keys()) == {'attributes', 'billable_units', 'names'}

    assert isinstance(values['billable_units'], int)
    assert 1 <= values['billable_units'] <= 3

    assert isinstance(values['names'], list)
    assert all(isinstance(country, str) for country in values['names'])

    assert isinstance(values['attributes'], dict)
    assert values['attributes']['dlr'] is None or isinstance(values['attributes']['dlr'], str)


def test_country_codes():

    assert len(COUNTRY_PREFIXES) == 214