Пример #1
0
    def test_countries_match_mnc_operators(self):
        operators = mobile_codes._mnc_operators()
        operator_mccs = set([o.mcc for o in operators])
        # exclude test / worldwide mcc values
        operator_mccs -= set([u'001', u'901'])
        # exclude:
        # 312 - Northern Michigan University
        operator_mccs -= set([u'312'])

        countries = mobile_codes._countries()
        countries_mccs = []
        for country in countries:
            mcc = country.mcc
            if not mcc:
                continue
            elif isinstance(mcc, list):
                countries_mccs.extend(list(mcc))
            else:
                countries_mccs.append(mcc)

        countries_mccs = set(countries_mccs)

        # No country should have a mcc value, without an operator
        self.assertEqual(countries_mccs - operator_mccs, set())

        # No operator should have a mcc value, without a matching country
        self.assertEqual(operator_mccs - countries_mccs, set())
Пример #2
0
    def test_countries_match_mnc_operators(self):
        operators = mobile_codes._mnc_operators()
        operator_mccs = set([o.mcc for o in operators])

        # Exclude test MCCs
        operator_mccs -= {"001", "999"}

        # Exclude international operators
        operator_mccs -= {"901", "902", "991"}

        countries = mobile_codes._countries()
        countries_mccs = []
        for country in countries:
            mcc = country.mcc
            if not mcc:
                continue
            elif isinstance(mcc, list):
                countries_mccs.extend(list(mcc))
            else:
                countries_mccs.append(mcc)

        countries_mccs = set(countries_mccs)

        # No country should have a mcc value, without an operator
        assert countries_mccs - operator_mccs == set()

        # No operator should have a mcc value, without a matching country
        assert operator_mccs - countries_mccs == set()
Пример #3
0
    def test_countries_match_mnc_operators(self):
        operators = mobile_codes._mnc_operators()
        operator_mccs = set([o.mcc for o in operators])
        # exclude test / worldwide mcc values
        operator_mccs -= set([u'001', u'901'])
        # exclude:
        # 312 - Northern Michigan University
        operator_mccs -= set([u'312'])

        countries = mobile_codes._countries()
        countries_mccs = []
        for country in countries:
            mcc = country.mcc
            if not mcc:
                continue
            elif isinstance(mcc, list):
                countries_mccs.extend(list(mcc))
            else:
                countries_mccs.append(mcc)

        countries_mccs = set(countries_mccs)

        # No country should have a mcc value, without an operator
        self.assertEqual(countries_mccs - operator_mccs, set())

        # No operator should have a mcc value, without a matching country
        self.assertEqual(operator_mccs - countries_mccs, set())
Пример #4
0
def get_countries_choices():
    from mobile_codes import _countries

    cl = _countries()
    r = [("", "---"), ]
    for c in cl:
        mcc = c[4]
        if mcc is None:
            continue
        if isinstance(mcc, tuple):
            mcc = ",".join(mcc)
        r.append((mcc, c[0]))
    return r
def get_countries_choices():
    from mobile_codes import _countries

    cl = _countries()
    r = [
        ("", "---"),
    ]
    for c in cl:
        mcc = c[4]
        if mcc is None:
            continue
        if isinstance(mcc, tuple):
            mcc = ",".join(mcc)
        r.append((mcc, c[0]))
    return r
Пример #6
0
# Challenger Deep, Mariana Trench.
MIN_ALTITUDE = -10911

# Karman Line, edge of space.
MAX_ALTITUDE = 100000

MAX_ALTITUDE_ACCURACY = abs(MAX_ALTITUDE - MIN_ALTITUDE)

MAX_HEADING = 360.0

# A bit less than speed of sound, in meters per second
MAX_SPEED = 300.0

ALL_VALID_MCCS = frozenset(
    [int(country.mcc)
     for country in mobile_codes._countries()
     if isinstance(country.mcc, basestring)] +
    [int(code)
     for country in mobile_codes._countries()
     if isinstance(country.mcc, (tuple, list))
     for code in country.mcc]
)

# We use a documentation-only multi-cast address as a test key
# http://tools.ietf.org/html/rfc7042#section-2.1.1
WIFI_TEST_KEY = '01005e901000'
INVALID_WIFI_REGEX = re.compile('(?!(0{12}|f{12}|%s))' % WIFI_TEST_KEY)
VALID_WIFI_REGEX = re.compile('([0-9a-fA-F]{12})')

MIN_WIFI_CHANNEL = 0
MAX_WIFI_CHANNEL = 166
Пример #7
0
 def test_mcc_iso_match(self):
     iso_alpha2 = set([rec.alpha2 for rec in iso3166._records])
     mcc_alpha2 = set([rec.alpha2 for rec in mobile_codes._countries()])
     self.assertEqual(iso_alpha2, mcc_alpha2)
Пример #8
0
 def test_countries(self):
     for country in _countries():
         trans = transliterate(country.name)
         non_ascii = [c for c in trans if ord(c) > 127]
         self.assertEqual(len(non_ascii), 0)
Пример #9
0
MIN_WIFI_CHANNEL = 0  #: Minimum accepted WiFi channel.
MAX_WIFI_CHANNEL = 166  #: Maximum accepted WiFi channel.

MIN_WIFI_SIGNAL = -100  #: Minimum accepted WiFi signal strength value.
MAX_WIFI_SIGNAL = -10  #: Maximum accepted WiFi signal strength value.

MIN_BLUE_SIGNAL = -127  #: Minimum accepted Bluetooth signal strength value.
MAX_BLUE_SIGNAL = 0  #: Maximum accepted Bluetooth signal strength value.

MIN_MCC = 1  #: Minimum accepted network code.
MAX_MCC = 999  #: Maximum accepted network code.

ALL_VALID_MCCS = (
    [int(record.mcc)
     for record in mobile_codes._countries()
     if isinstance(record.mcc, string_types)] +
    [int(code)
     for record in mobile_codes._countries()
     if isinstance(record.mcc, (tuple, list))
     for code in record.mcc]
)  #: All valid mobile country codes.
ALL_VALID_MCCS = set(
    [mcc for mcc in ALL_VALID_MCCS if MIN_MCC <= mcc <= MAX_MCC])
# exclude Tuvalu, as it isn't in our shapefile
ALL_VALID_MCCS = frozenset(ALL_VALID_MCCS - set([553]))

MIN_MNC = 0  #: Minimum accepted network code.
MAX_MNC = 999  #: Maximum accepted network code.

MIN_LAC = 1  #: Minimum accepted cell area code.
Пример #10
0
VALID_APIKEY_REGEX = re.compile('^[-0-9a-z]+$', re.IGNORECASE | re.UNICODE)

MIN_WIFI_CHANNEL = 0  #: Minimum accepted WiFi channel.
MAX_WIFI_CHANNEL = 166  #: Maximum accepted WiFi channel.

MIN_WIFI_SIGNAL = -100  #: Minimum accepted WiFi signal strength value.
MAX_WIFI_SIGNAL = -10  #: Maximum accepted WiFi signal strength value.

MIN_BLUE_SIGNAL = -127  #: Minimum accepted Bluetooth signal strength value.
MAX_BLUE_SIGNAL = 0  #: Maximum accepted Bluetooth signal strength value.

MIN_MCC = 1  #: Minimum accepted network code.
MAX_MCC = 999  #: Maximum accepted network code.

ALL_VALID_MCCS = ([
    int(record.mcc) for record in mobile_codes._countries()
    if isinstance(record.mcc, string_types)
] + [
    int(code) for record in mobile_codes._countries()
    if isinstance(record.mcc, (tuple, list)) for code in record.mcc
])  #: All valid mobile country codes.
ALL_VALID_MCCS = set(
    [mcc for mcc in ALL_VALID_MCCS if MIN_MCC <= mcc <= MAX_MCC])
# exclude Tuvalu, as it isn't in our shapefile
ALL_VALID_MCCS = frozenset(ALL_VALID_MCCS - set([553]))

MIN_MNC = 0  #: Minimum accepted network code.
MAX_MNC = 999  #: Maximum accepted network code.

MIN_LAC = 1  #: Minimum accepted cell area code.
MAX_LAC = 65533  #: Maximum accepted cell area code.
Пример #11
0
 def test_countries(self):
     for country in _countries():
         trans = transliterate(country.name)
         non_ascii = [c for c in trans if ord(c) > 127]
         self.assertEqual(len(non_ascii), 0)
Пример #12
0
# Challenger Deep, Mariana Trench.
MIN_ALTITUDE = -10911

# Karman Line, edge of space.
MAX_ALTITUDE = 100000

MAX_ALTITUDE_ACCURACY = abs(MAX_ALTITUDE - MIN_ALTITUDE)

MAX_HEADING = 360.0

# A bit less than speed of sound, in meters per second
MAX_SPEED = 300.0

ALL_VALID_MCCS = frozenset([
    int(country.mcc) for country in mobile_codes._countries()
    if isinstance(country.mcc, basestring)
] + [
    int(code) for country in mobile_codes._countries()
    if isinstance(country.mcc, (tuple, list)) for code in country.mcc
])

# We use a documentation-only multi-cast address as a test key
# http://tools.ietf.org/html/rfc7042#section-2.1.1
WIFI_TEST_KEY = '01005e901000'
INVALID_WIFI_REGEX = re.compile('(?!(0{12}|f{12}|%s))' % WIFI_TEST_KEY)
VALID_WIFI_REGEX = re.compile('([0-9a-fA-F]{12})')

MIN_WIFI_CHANNEL = 0
MAX_WIFI_CHANNEL = 166
Пример #13
0
# Challenger Deep, Mariana Trench.
MIN_ALTITUDE = -10911

# Karman Line, edge of space.
MAX_ALTITUDE = 100000

MAX_ALTITUDE_ACCURACY = abs(MAX_ALTITUDE - MIN_ALTITUDE)

MAX_HEADING = 360.0

# A bit less than speed of sound, in meters per second
MAX_SPEED = 300.0

ALL_VALID_MCCS = frozenset([
    int(country.mcc)
    for country in mobile_codes._countries() if isinstance(country.mcc, str)
] + [
    int(code)
    for country in mobile_codes._countries() if isinstance(country.mcc, tuple)
    for code in country.mcc
])

# We use a documentation-only multi-cast address as a test key
# http://tools.ietf.org/html/rfc7042#section-2.1.1
WIFI_TEST_KEY = "01005e901000"
INVALID_WIFI_REGEX = re.compile("(?!(0{12}|f{12}|%s))" % WIFI_TEST_KEY)
VALID_WIFI_REGEX = re.compile("([0-9a-fA-F]{12})")


def valid_wifi_pattern(key):
    return INVALID_WIFI_REGEX.match(key) and \
Пример #14
0
MIN_WIFI_SIGNAL = -100  # Minimum accepted WiFi signal strength value.
MAX_WIFI_SIGNAL = -10  # Maximum accepted WiFi signal strength value.

MIN_WIFI_SNR = 1  # Minimum accepted WiFi signal to noise ratio.
MAX_WIFI_SNR = 100  # Maximum accepted WiFi signal to noise ratio.

MIN_BLUE_SIGNAL = -127  # Minimum accepted Bluetooth signal strength value.
MAX_BLUE_SIGNAL = 0  # Maximum accepted Bluetooth signal strength value.

MIN_MCC = 1  # Minimum accepted network code.
MAX_MCC = 999  # Maximum accepted network code.

ALL_VALID_MCCS = [
    int(record.mcc)
    for record in mobile_codes._countries() if isinstance(record.mcc, str)
] + [
    int(code) for record in mobile_codes._countries()
    if isinstance(record.mcc, (tuple, list)) for code in record.mcc
]  # All valid mobile country codes.
ALL_VALID_MCCS = set(
    [mcc for mcc in ALL_VALID_MCCS if MIN_MCC <= mcc <= MAX_MCC])
# exclude Tuvalu, as it isn't in our shapefile
ALL_VALID_MCCS = frozenset(ALL_VALID_MCCS - set([553]))

MIN_MNC = 0  # Minimum accepted network code.
MAX_MNC = 999  # Maximum accepted network code.

MIN_LAC = 1  # Minimum accepted cell area code.
MAX_LAC = 65533  # Maximum accepted cell area code.
MIN_WIFI_SIGNAL = -100  # Minimum accepted WiFi signal strength value.
MAX_WIFI_SIGNAL = -10  # Maximum accepted WiFi signal strength value.

MIN_WIFI_SNR = 1  # Minimum accepted WiFi signal to noise ratio.
MAX_WIFI_SNR = 100  # Maximum accepted WiFi signal to noise ratio.

MIN_BLUE_SIGNAL = -127  # Minimum accepted Bluetooth signal strength value.
MAX_BLUE_SIGNAL = 0  # Maximum accepted Bluetooth signal strength value.

MIN_MCC = 1  # Minimum accepted network code.
MAX_MCC = 999  # Maximum accepted network code.

ALL_VALID_MCCS = (
    [int(record.mcc)
     for record in mobile_codes._countries()
     if isinstance(record.mcc, str)] +
    [int(code)
     for record in mobile_codes._countries()
     if isinstance(record.mcc, (tuple, list))
     for code in record.mcc]
)  # All valid mobile country codes.
ALL_VALID_MCCS = set(
    [mcc for mcc in ALL_VALID_MCCS if MIN_MCC <= mcc <= MAX_MCC])
# exclude Tuvalu, as it isn't in our shapefile
ALL_VALID_MCCS = frozenset(ALL_VALID_MCCS - set([553]))

MIN_MNC = 0  # Minimum accepted network code.
MAX_MNC = 999  # Maximum accepted network code.

MIN_LAC = 1  # Minimum accepted cell area code.