Пример #1
0
class RouteDataTest(TestCase):
    def setUp(self):
        self.data = RouteData()
        self.db = self.data.db

    def test_version(self):
        self.assertEqual(self.data.version, '20110905')

    def test_get_country(self):
        self.assertRaises(CountryError, self.data.get_countrynum, 'URW')
        self.assertEqual(self.data.get_countrynum('JP'), '392')
        self.assertEqual(self.data.get_countrynum('DE'), '276')
        self.assertEqual(self.data.get_countrynum('de'), '276')

    def test_read_depots(self):
        c = self.db.cursor()
        c.execute("""SELECT * FROM depots WHERE DepotNumber=?""", ('0015', ))
        rows = c.fetchall()
        self.assertEqual(1, len(rows))
        self.assertEqual(
            ('0015', '', '', 'Betriebsgesellschaft DPD GmbH', '',
             'Otto-Hahn-Strasse 5', '', '59423', 'Unna', 'DE',
             '+49-(0) 23 03-8 88-0', '+49-(0) 23 03-8 88-31', '', ''), rows[0])

    def test_expand_depots(self):
        c = self.db.cursor()
        c.execute("""SELECT id
                     FROM routes
                     WHERE DestinationCountry='DE' AND BeginPostCode='42477'"""
                  )
        rows = c.fetchall()
        # Interestingly we sometimes get two routes
        # self.assertEqual(1, len(rows))
        route = rows[0][0]
        c.execute("SELECT depot FROM routedepots WHERE route=?", (route, ))
        rows = c.fetchall()
        self.assertEqual(1, len(rows))

    def test_get_service(self):
        self.assertEqual(self.data.get_service('180'),
                         ('180', 'AM1-NO', '', '022,160', ''))
        self.assertRaises(ServiceError, self.data.get_service, '100000')

    def test_get_servicetext(self):
        text = self.data.get_servicetext('185')
        self.assertEqual('DPD 10:00 Unfrei / ex works', text)

    def test_translate_location(self):
        self.assertEqual('1', self.data.translate_location('Dublin', 'IE'))
        self.assertRaises(TranslationError, self.data.translate_location,
                          'Cahir', 'IE')
Пример #2
0
class RouteDataTest(TestCase):

    def setUp(self):
        self.data = RouteData()
        self.db = self.data.db

    def test_version(self):
        self.assertEqual(self.data.version, '20100503')

    def test_get_country(self):
        self.assertRaises(CountryError, self.data.get_countrynum, 'URW')
        self.assertEqual(self.data.get_countrynum('JP'), '392')
        self.assertEqual(self.data.get_countrynum('DE'), '276')
        self.assertEqual(self.data.get_countrynum('de'), '276')

    def test_read_depots(self):
        c = self.db.cursor()
        c.execute("""SELECT * FROM depots WHERE DepotNumber=?""", ('0015', ))
        rows = c.fetchall()
        self.assertEqual(1, len(rows))
        self.assertEqual(('0015', '', '', 'Betriebsgesellschaft DPD Deutscher',
                          '', 'Otto-Hahn-Strasse 5', '', '59423', 'Unna', 'DE',
                          '+49-(0) 23 03-8 88-0', '+49-(0) 23 03-8 88-31', '', ''),
                         rows[0])

    def test_expand_depots(self):
        c = self.db.cursor()
        c.execute("""SELECT id
                     FROM routes
                     WHERE DestinationCountry='DE' AND BeginPostCode='42477'""")
        rows = c.fetchall()
        # Interestingly we sometimes get two routes
        # self.assertEqual(1, len(rows))
        route = rows[0][0]
        c.execute("SELECT depot FROM routedepots WHERE route=?", (route, ))
        rows = c.fetchall()
        self.assertEqual(1, len(rows))

    def test_get_service(self):
        self.assertEqual(self.data.get_service('180'), ('180', 'AM1-NO', '', '022,160', ''))
        self.assertRaises(ServiceError, self.data.get_service, '100000')

    def test_get_servicetext(self):
        text = self.data.get_servicetext('185')
        self.assertEqual('DPD 10:00 Unfrei / ex works', text)

    def test_translate_location(self):
        self.assertEqual('1', self.data.translate_location('Dublin', 'IE'))
        self.assertRaises(TranslationError, self.data.translate_location, 'Cahir', 'IE')