예제 #1
0
 def test_valid(self):
     carrier_details = set([c['slug'] for c in CARRIER_DETAILS.values()])
     diff = carrier_details.difference(set(CARRIER_SLUGS))
     assert not diff, 'Extra carriers: %s' % diff
예제 #2
0
 def test_unique_slugs(self):
     ids = [c['slug'] for c in CARRIER_DETAILS.values()]
     most = Counter(ids).most_common(1)[0]
     assert most[1] == 1, 'Id: %s occurred %s times' % (most[0], most[1])
예제 #3
0
# -*- coding: utf-8 -*-
from mpconstants.carriers import CARRIER_DETAILS


class CARRIER(object):
    pass


for k, carrier in CARRIER_DETAILS.items():
    # Create a CARRIER objects for each carrier and add it to locals so that we
    # can import them from this module.
    locals()[k] = type(k, (CARRIER,), carrier)

CARRIER_MAP = dict((c.slug, c) for name, c in locals().items() if
                   type(c) is type and c != CARRIER and issubclass(c, CARRIER))
CARRIERS = CARRIER_MAP.values()

CARRIER_IDS = frozenset([c.id for c in CARRIERS])
CARRIER_SLUGS = frozenset([c.slug for c in CARRIERS])
CARRIER_CHOICES = [(c.id, c) for c in CARRIERS]
CARRIER_CHOICE_DICT = dict(CARRIER_CHOICES)
예제 #4
0
 def test_no_missing_carrier(self):
     defined_carriers = carriers.CARRIER_SLUGS
     available_carriers = {c['slug'] for c in CARRIER_DETAILS.values()}
     eq_(list(available_carriers.difference(defined_carriers)), [])
예제 #5
0
 def test_unique_slugs(self):
     ids = [c['slug'] for c in CARRIER_DETAILS.values()]
     most = Counter(ids).most_common(1)[0]
     assert most[1] == 1, 'Id: %s occurred %s times' % (most[0], most[1])
예제 #6
0
 def test_valid(self):
     carrier_details = set([c['slug'] for c in CARRIER_DETAILS.values()])
     diff = carrier_details.difference(set(CARRIER_SLUGS))
     assert not diff, 'Extra carriers: %s' % diff
예제 #7
0
# -*- coding: utf-8 -*-
from mpconstants.carriers import CARRIER_DETAILS


class CARRIER(object):
    pass


for k, carrier in CARRIER_DETAILS.items():
    # Create a CARRIER objects for each carrier and add it to locals so that we
    # can import them from this module.
    locals()[k] = type(k, (CARRIER, ), carrier)

CARRIER_MAP = dict(
    (c.slug, c) for name, c in locals().items()
    if type(c) is type and c != CARRIER and issubclass(c, CARRIER))
CARRIERS = CARRIER_MAP.values()

CARRIER_IDS = frozenset([c.id for c in CARRIERS])
CARRIER_SLUGS = frozenset([c.slug for c in CARRIERS])
CARRIER_CHOICES = [(c.id, c) for c in CARRIERS]
CARRIER_CHOICE_DICT = dict(CARRIER_CHOICES)