Пример #1
0
def test_country_networks():
    nets = country_networks('US')
    for n in nets:
        mcc, mnc, name0 = n
        c, name1 = network(mcc, mnc)
        assert c == 'US'
        assert name0 == name1
Пример #2
0
def mk_onboarding_json(tc_version="8.12.59"):
    phone = input("Enter your phone with country code: ")
    prefix, country = phone_country_prefix(phone)
    networks = country_networks(country)
    v_build, v_major, v_minor = tuple(map(int, tc_version.split(".")))

    for i, network in enumerate(networks, start=1):
        print(f"{i}. {network[2]}")

    while True:
        try:
            option = int(input("\nChoose your oparator: "))
            network = networks[option - 1]
            break
        except (IndexError, ValueError):
            print(f"Please enter a number between 1 and {len(networks)}")

    onboarding_json_tmpl["countryCode"] = country.lower()
    onboarding_json_tmpl["dialingCode"] = prefix
    onboarding_json_tmpl["phoneNumber"] = phone.strip("+").replace(
        str(prefix), "", 1)
    onboarding_json_tmpl["installationDetails"]["sims"][0][
        "mcc"] = f"{network[0]:0>3}"
    onboarding_json_tmpl["installationDetails"]["sims"][0][
        "mnc"] = f"{network[1]:0>3}"
    onboarding_json_tmpl["installationDetails"]["sims"][0][
        "operator"] = network[2].split(" ")[0]
    onboarding_json_tmpl["installationDetails"]["sims"][0][
        "imsi"] = genarate_imsi(network[0], network[1])
    onboarding_json_tmpl["installationDetails"]["device"][
        "deviceId"] = "7" + "".join(
            [random.choice(string.hexdigits[:16]) for _ in range(15)])
    onboarding_json_tmpl["installationDetails"]["device"]["simSerials"] = [
        genarate_iccid(
            onboarding_json_tmpl["installationDetails"]["sims"][0]["imsi"])
    ]
    onboarding_json_tmpl["installationDetails"]["app"][
        "buildVersion"] = v_build
    onboarding_json_tmpl["installationDetails"]["app"][
        "majorVersion"] = v_major
    onboarding_json_tmpl["installationDetails"]["app"][
        "minorVersion"] = v_minor

    return onboarding_json_tmpl
Пример #3
0
def test_invalid_country():
    with pytest.raises(InvalidCountry):
        country_networks('XX')