Exemplo n.º 1
0
    def test_parsing_short_pass(self):

        mpan = MPAN("1099999999997")

        self.assertIsNone(mpan.profile_class)
        self.assertIsNone(mpan.meter_time_switch_code)
        self.assertIsNone(mpan.line_loss_factor_class)
        self.assertEqual(mpan.core, "1099999999997")
        self.assertEqual(mpan.distributor.identifier, "10")
        self.assertEqual(mpan.identifier, "99999999")
        self.assertEqual(mpan.checksum, "7")

        # Aliases
        self.assertIsNone(mpan.pc)
        self.assertIsNone(mpan.mtc)
        self.assertIsNone(mpan.llfc)
Exemplo n.º 2
0
    def test_parsing_long_pass(self):

        mpan = MPAN("018011002099999999386")

        self.assertEqual(mpan.top_line, "01801100")
        self.assertEqual(mpan.profile_class.identifier, "01")
        self.assertEqual(mpan.meter_time_switch_code.identifier, "801")
        self.assertEqual(mpan.line_loss_factor_class, "100")
        self.assertEqual(mpan.core, "2099999999386")
        self.assertEqual(mpan.distributor.identifier, "20")
        self.assertEqual(mpan.identifier, "99999999")
        self.assertEqual(mpan.checksum, "6")

        # Aliases
        self.assertEqual(mpan.pc.identifier, "01")
        self.assertEqual(mpan.mtc.identifier, "801")
        self.assertEqual(mpan.llfc, "100")
Exemplo n.º 3
0
 def test_check_fail(self):
     for string in INVALID:
         with self.subTest(string=string):
             self.assertRaises(InvalidMPANError, MPAN(string).check)
Exemplo n.º 4
0
 def test_check_pass(self):
     for string in get_valid_mpans():
         with self.subTest(string=string):
             self.assertIsNone(MPAN(string).check())
Exemplo n.º 5
0
 def test_is_valid_fail(self):
     for string in INVALID:
         with self.subTest(string=string):
             self.assertFalse(MPAN(string).is_valid)
Exemplo n.º 6
0
 def test_is_valid(self):
     for string in get_valid_mpans():
         with self.subTest(string=string):
             self.assertTrue(MPAN(string).is_valid)
Exemplo n.º 7
0
 def test_as_short(self):
     self.assertEqual(MPAN("1099999999997").as_short, "1099999999997")
     self.assertEqual(
         MPAN("018011002099999999386").as_short, "2099999999386")
Exemplo n.º 8
0
 def test_is_long(self):
     self.assertFalse(MPAN("1030006718997").is_long)
     self.assertTrue(MPAN("018011002099999999386").is_long)
Exemplo n.º 9
0
 def test_is_short(self):
     self.assertTrue(MPAN("1099999999997").is_short)
     self.assertFalse(MPAN("018011002099999999386").is_short)
Exemplo n.º 10
0
 def test___eq__with_foreign_objects(self):
     mpan_string = "108011002099999999386"
     self.assertNotEqual(MPAN(mpan_string), mpan_string)
     self.assertNotEqual(MPAN(mpan_string), 108011002099999999386)
     self.assertNotEqual(MPAN(mpan_string), "twelve")
Exemplo n.º 11
0
 def test___eq__with_invalid_mpans(self):
     for string in INVALID:
         self.assertEqual(MPAN(string), MPAN(string))
Exemplo n.º 12
0
 def test___eq__with_valid_mpans(self):
     for string in get_valid_mpans():
         self.assertEqual(MPAN(string), MPAN(string))
Exemplo n.º 13
0
 def test___repr__(self):
     self.assertEqual(repr(MPAN("018011002099999999386")),
                      "018011002099999999386")
Exemplo n.º 14
0
 def test___str__(self):
     self.assertEqual(str(MPAN("018011002099999999386")),
                      "018011002099999999386")