Exemplo n.º 1
0
    def test_import_fare_attributes_maximal(self):
        fare_attributes_txt = StringIO.StringIO("""\
fare_id,price,currency_type,payment_method,transfers,transfer_duration
p,1.25,USD,0,0,60
""")
        Fare.import_txt(fare_attributes_txt, self.feed)
        fa = Fare.objects.get()
        self.assertEqual(fa.transfer_duration, 60)
Exemplo n.º 2
0
    def test_import_fare_attributes_maximal(self):
        fare_attributes_txt = StringIO("""\
fare_id,price,currency_type,payment_method,transfers,transfer_duration
p,1.25,USD,0,0,60
""")
        Fare.import_txt(fare_attributes_txt, self.feed)
        fa = Fare.objects.get()
        self.assertEqual(fa.transfer_duration, 60)
Exemplo n.º 3
0
    def test_import_fare_attributes_unlimited_transfers(self):
        fare_attributes_txt = StringIO("""\
fare_id,price,currency_type,payment_method,transfers,transfer_duration
p,1.25,USD,0,,3600
""")
        Fare.import_txt(fare_attributes_txt, self.feed)
        fa = Fare.objects.get()
        self.assertEqual(fa.fare_id, 'p')
        self.assertEqual(fa.transfers, None)
        self.assertEqual(fa.transfer_duration, 3600)
Exemplo n.º 4
0
    def test_import_fare_duplicate_fare_id(self):
        fare_attributes_txt = StringIO("""\
fare_id,price,currency_type,payment_method,transfers
p,1.25,USD,0,0
p,1.25,USD,0,0
""")
        Fare.import_txt(fare_attributes_txt, self.feed)
        fa = Fare.objects.get()  # Just one
        self.assertEqual(fa.feed, self.feed)
        self.assertEqual(fa.fare_id, 'p')
Exemplo n.º 5
0
    def test_import_fare_attributes_unlimited_transfers(self):
        fare_attributes_txt = StringIO.StringIO("""\
fare_id,price,currency_type,payment_method,transfers,transfer_duration
p,1.25,USD,0,,3600
""")
        Fare.import_txt(fare_attributes_txt, self.feed)
        fa = Fare.objects.get()
        self.assertEqual(fa.fare_id, 'p')
        self.assertEqual(fa.transfers, None)
        self.assertEqual(fa.transfer_duration, 3600)
Exemplo n.º 6
0
    def test_import_fare_duplicate_fare_id(self):
        fare_attributes_txt = StringIO("""\
fare_id,price,currency_type,payment_method,transfers
p,1.25,USD,0,0
p,1.25,USD,0,0
""")
        Fare.import_txt(fare_attributes_txt, self.feed)
        fa = Fare.objects.get()  # Just one
        self.assertEqual(fa.feed, self.feed)
        self.assertEqual(fa.fare_id, 'p')
Exemplo n.º 7
0
    def test_import_fare_attributes_minimal(self):
        fare_attributes_txt = StringIO.StringIO("""\
fare_id,price,currency_type,payment_method,transfers
p,1.25,USD,0,0
""")
        Fare.import_txt(fare_attributes_txt, self.feed)
        fa = Fare.objects.get()
        self.assertEqual(fa.feed, self.feed)
        self.assertEqual(fa.fare_id, 'p')
        self.assertEqual(str(fa.price), '1.25')
        self.assertEqual(fa.currency_type, 'USD')
        self.assertEqual(fa.payment_method, 0)
        self.assertEqual(fa.transfers, 0)
        self.assertEqual(fa.transfer_duration, None)
Exemplo n.º 8
0
    def test_export_fare_attributes_minimal(self):
        Fare.objects.create(
            feed=self.feed, fare_id='p', price='1.25', currency_type='USD',
            payment_method=0, transfers=0)
        fare = Fare.objects.get()
        fare_txt = Fare.export_txt(self.feed)
        self.assertEqual(fare_txt, """\
fare_id,price,currency_type,payment_method,transfers
p,%s,USD,0,0
""" % fare.price)
Exemplo n.º 9
0
    def test_export_fare_attributes_unlimited_transfers(self):
        Fare.objects.create(
            feed=self.feed, fare_id='p', price='1.25', currency_type='USD',
            payment_method=0, transfers=None, transfer_duration=3600)
        fare = Fare.objects.get()
        fare_txt = Fare.export_txt(self.feed)
        self.assertEqual(fare_txt, """\
fare_id,price,currency_type,payment_method,transfers,transfer_duration
p,%s,USD,0,,3600
""" % fare.price)
Exemplo n.º 10
0
    def test_export_fare_attributes_minimal(self):
        Fare.objects.create(feed=self.feed,
                            fare_id='p',
                            price='1.25',
                            currency_type='USD',
                            payment_method=0,
                            transfers=0)
        fare = Fare.objects.get()
        fare_txt = Fare.export_txt(self.feed)
        self.assertEqual(
            fare_txt, """\
fare_id,price,currency_type,payment_method,transfers
p,%s,USD,0,0
""" % fare.price)
Exemplo n.º 11
0
    def test_export_fare_attributes_unlimited_transfers(self):
        Fare.objects.create(feed=self.feed,
                            fare_id='p',
                            price='1.25',
                            currency_type='USD',
                            payment_method=0,
                            transfers=None,
                            transfer_duration=3600)
        fare = Fare.objects.get()
        fare_txt = Fare.export_txt(self.feed)
        self.assertEqual(
            fare_txt, """\
fare_id,price,currency_type,payment_method,transfers,transfer_duration
p,%s,USD,0,,3600
""" % fare.price)