def test_import_two_same_id(self):
        agency_txt = StringIO("""\
agency_id,agency_name,agency_url,agency_timezone
DTA,Demo Transit Authority,http://google.com,America/Los_Angeles
DTA,Example Transit Authority,http://example.com,America/Los_Angeles
""")
        Agency.import_txt(agency_txt, self.feed)
        agency = Agency.objects.get()  # Just one
        self.assertEqual(agency.agency_id, 'DTA')
        self.assertEqual(agency.name, 'Demo Transit Authority')
    def test_import_two_same_id(self):
        agency_txt = StringIO("""\
agency_id,agency_name,agency_url,agency_timezone
DTA,Demo Transit Authority,http://google.com,America/Los_Angeles
DTA,Example Transit Authority,http://example.com,America/Los_Angeles
""")
        Agency.import_txt(agency_txt, self.feed)
        agency = Agency.objects.get()  # Just one
        self.assertEqual(agency.agency_id, 'DTA')
        self.assertEqual(agency.name, 'Demo Transit Authority')
    def test_import_minimal(self):
        agency_txt = StringIO("""\
agency_name,agency_url,agency_timezone
Demo Transit Authority,http://google.com,America/Los_Angeles
""")
        Agency.import_txt(agency_txt, self.feed)
        agency = Agency.objects.get()
        self.assertEqual(agency.agency_id, '')
        self.assertEqual(agency.name, 'Demo Transit Authority')
        self.assertEqual(agency.url, 'http://google.com')
        self.assertEqual(agency.timezone, 'America/Los_Angeles')
        self.assertEqual(agency.lang, '')
        self.assertEqual(agency.phone, '')
        self.assertEqual(agency.fare_url, '')
Exemple #4
0
    def test_import_minimal(self):
        agency_txt = StringIO.StringIO("""\
agency_name,agency_url,agency_timezone
Demo Transit Authority,http://google.com,America/Los_Angeles
""")
        Agency.import_txt(agency_txt, self.feed)
        agency = Agency.objects.get()
        self.assertEqual(agency.agency_id, '')
        self.assertEqual(agency.name, 'Demo Transit Authority')
        self.assertEqual(agency.url, 'http://google.com')
        self.assertEqual(agency.timezone, 'America/Los_Angeles')
        self.assertEqual(agency.lang, '')
        self.assertEqual(agency.phone, '')
        self.assertEqual(agency.fare_url, '')
    def test_import_agency_maximal(self):
        agency_txt = StringIO("""\
agency_id,agency_name,agency_url,agency_timezone,agency_lang,agency_phone,\
agency_fare_url
DTA,"Demo Transit Authority",http://google.com,America/Los_Angeles,en,\
555-555-TEST,http://google.com
""")
        Agency.import_txt(agency_txt, self.feed)
        agency = Agency.objects.get()
        self.assertEqual(agency.agency_id, 'DTA')
        self.assertEqual(agency.name, 'Demo Transit Authority')
        self.assertEqual(agency.url, 'http://google.com')
        self.assertEqual(agency.timezone, 'America/Los_Angeles')
        self.assertEqual(agency.lang, 'en')
        self.assertEqual(agency.phone, '555-555-TEST')
        self.assertEqual(agency.fare_url, 'http://google.com')
Exemple #6
0
    def test_import_agency_maximal(self):
        agency_txt = StringIO.StringIO("""\
agency_id,agency_name,agency_url,agency_timezone,agency_lang,agency_phone,\
agency_fare_url
DTA,"Demo Transit Authority",http://google.com,America/Los_Angeles,en,\
555-555-TEST,http://google.com
""")
        Agency.import_txt(agency_txt, self.feed)
        agency = Agency.objects.get()
        self.assertEqual(agency.agency_id, 'DTA')
        self.assertEqual(agency.name, 'Demo Transit Authority')
        self.assertEqual(agency.url, 'http://google.com')
        self.assertEqual(agency.timezone, 'America/Los_Angeles')
        self.assertEqual(agency.lang, 'en')
        self.assertEqual(agency.phone, '555-555-TEST')
        self.assertEqual(agency.fare_url, 'http://google.com')
    def test_export_agency_minimal(self):
        Agency.objects.create(
            feed=self.feed, name='Demo Transit Authority',
            url='http://google.com', timezone='America/Los_Angeles')
        agency_txt = Agency.export_txt(self.feed)
        self.assertEqual(agency_txt, """\
agency_name,agency_url,agency_timezone
Demo Transit Authority,http://google.com,America/Los_Angeles
""")
    def test_export_agency_minimal(self):
        Agency.objects.create(feed=self.feed,
                              name='Demo Transit Authority',
                              url='http://google.com',
                              timezone='America/Los_Angeles')
        agency_txt = Agency.export_txt(self.feed)
        self.assertEqual(
            agency_txt, """\
agency_name,agency_url,agency_timezone
Demo Transit Authority,http://google.com,America/Los_Angeles
""")
    def test_import_bom(self):
        if PY3:  # pragma: no cover
            text = (BOM_UTF8.decode('utf-8') + """\
agency_name,agency_url,agency_timezone
Demo Transit Authority,http://google.com,America/Los_Angeles
""")
        else:
            text = (BOM_UTF8 + b"""\
agency_name,agency_url,agency_timezone
Demo Transit Authority,http://google.com,America/Los_Angeles
""")
        agency_txt = StringIO(text)
        Agency.import_txt(agency_txt, self.feed)
        agency = Agency.objects.get()
        self.assertEqual(agency.agency_id, '')
        self.assertEqual(agency.name, 'Demo Transit Authority')
        self.assertEqual(agency.url, 'http://google.com')
        self.assertEqual(agency.timezone, 'America/Los_Angeles')
        self.assertEqual(agency.lang, '')
        self.assertEqual(agency.phone, '')
        self.assertEqual(agency.fare_url, '')
    def test_export_agency_maximal(self):
        Agency.objects.create(
            feed=self.feed, agency_id='DTA', name='Demo Transit Authority',
            url='http://google.com', timezone='America/Los_Angeles',
            lang='en', phone='555-555-TEST', fare_url='http://google.com')
        agency_txt = Agency.export_txt(self.feed)
        self.assertEqual(agency_txt, """\
agency_id,agency_name,agency_url,agency_timezone,agency_lang,agency_phone,\
agency_fare_url
DTA,Demo Transit Authority,http://google.com,America/Los_Angeles,en,\
555-555-TEST,http://google.com
""")
Exemple #11
0
    def test_import_bom(self):
        if PY3:  # pragma: no cover
            text = (BOM_UTF8.decode('utf-8') + """\
agency_name,agency_url,agency_timezone
Demo Transit Authority,http://google.com,America/Los_Angeles
""")
        else:
            text = (BOM_UTF8 + b"""\
agency_name,agency_url,agency_timezone
Demo Transit Authority,http://google.com,America/Los_Angeles
""")
        agency_txt = StringIO(text)
        Agency.import_txt(agency_txt, self.feed)
        agency = Agency.objects.get()
        self.assertEqual(agency.agency_id, '')
        self.assertEqual(agency.name, 'Demo Transit Authority')
        self.assertEqual(agency.url, 'http://google.com')
        self.assertEqual(agency.timezone, 'America/Los_Angeles')
        self.assertEqual(agency.lang, '')
        self.assertEqual(agency.phone, '')
        self.assertEqual(agency.fare_url, '')
    def test_export_agency_maximal(self):
        Agency.objects.create(feed=self.feed,
                              agency_id='DTA',
                              name='Demo Transit Authority',
                              url='http://google.com',
                              timezone='America/Los_Angeles',
                              lang='en',
                              phone='555-555-TEST',
                              fare_url='http://google.com')
        agency_txt = Agency.export_txt(self.feed)
        self.assertEqual(
            agency_txt, """\
agency_id,agency_name,agency_url,agency_timezone,agency_lang,agency_phone,\
agency_fare_url
DTA,Demo Transit Authority,http://google.com,America/Los_Angeles,en,\
555-555-TEST,http://google.com
""")
 def test_export_agency_none(self):
     agency_txt = Agency.export_txt(self.feed)
     self.assertFalse(agency_txt)
 def test_export_agency_none(self):
     agency_txt = Agency.export_txt(self.feed)
     self.assertFalse(agency_txt)