本文整理汇总了Python中models.Ticket.price方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.price方法的具体用法?Python Ticket.price怎么用?Python Ticket.price使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Ticket
的用法示例。
在下文中一共展示了Ticket.price方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_ticket
# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import price [as 别名]
def handle_ticket(info):
context_dict = {}
ticket = Ticket()
order = info["GtETicket_Response"]["Order"]
ticket.order_id = order["@ID"]
ticket.express_id = order["@ExpressID"]
departure = info["GtETicket_Response"]["Departure"]
ticket.train = departure["@Train"]
ticket.departure_date = departure["@Date"]
ticket.departure_time = departure["@Time"]
ticket.departure_station = departure["@Station"]
arrival = info["GtETicket_Response"]["Arrival"]
ticket.arrival_date = arrival["@Date"]
ticket.arrival_time = arrival["@Time"]
ticket.arrival_station = arrival["@Station"]
car = info["GtETicket_Response"]["Car"]
ticket.car_number = car["@Number"]
ticket.car_type = car["@Type"]
ticket.seat_number = info["GtETicket_Response"]["Seats"]["Seat"]
ticket.price = info["GtETicket_Response"]["Tariff"]
ticket.full_name = info["GtETicket_Response"]["Tickets"]["Ticket"]["Passenger"]["@Name"]
ticket.save()
context_dict['ticket'] = ticket
return context_dict
示例2: TicketTestCase
# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import price [as 别名]
class TicketTestCase(TestCase):
"""
TODO
"""
def setUp(self):
"""
TODO
"""
stadium = Stadium(name="test stadium")
stadium.save()
self.sector = Sector(stadium=stadium, letter="A", color="#00ff00",
rows=10, sits=10, price=Decimal("10.00"))
self.sector.save()
self.festival = Festival(stadium=stadium, name="test festival",
base_price=Decimal("10.00"))
self.festival.save()
start_night = datetime.now() + timedelta(days=50)
self.night = Night(festival=self.festival, datetime=start_night)
self.night.save()
for i in range(2):
band = Band(name="Test band %d" % i)
band.save()
self.bbn = BandByNight(band=band, night=self.night,
price=Decimal("5.00"))
self.bbn.save()
self.pt = PublicType(name="maxor", price=Decimal("10.00"))
self.pt.save()
self.discount = Discount(festival=self.festival, limit_days=30,
porcent=Decimal("10.00"))
self.discount.save()
self.ticket = Ticket(night=self.night, sector=self.sector, row=1,
sit=1, public_type=self.pt)
self.ticket.save()
def testPriceWithDiscount(self):
"""
TODO
"""
price = self.sector.price + self.night.price() + self.pt.price
price -= price * (self.discount.porcent / Decimal("100.00"))
self.assertEquals(price, self.ticket.price())
def testPriceWithoutDiscount(self):
"""
TODO
"""
self.night.datetime = datetime.now() + timedelta(days=1)
self.night.save()
price = self.sector.price + self.night.price() + self.pt.price
self.assertEquals(price, self.ticket.price())
def testInvalidPosition(self):
"""
TODO
"""
with self.assertRaises(ValidationError):
ticket = Ticket(night=self.night, sector=self.sector, row=100,
sit=1, public_type=self.pt)
ticket.clean()
with self.assertRaises(ValidationError):
ticket = Ticket(night=self.night, sector=self.sector, row=1,
sit=100, public_type=self.pt)
ticket.clean()
def testUniqueTicket(self):
"""
TODO
"""
with self.assertRaises(IntegrityError):
self.ticket = Ticket(night=self.night, sector=self.sector, row=1,
sit=1, public_type=self.pt)
self.ticket.save()
示例3: CancellationTestCase
# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import price [as 别名]
class CancellationTestCase(TestCase):
"""
TODO
"""
def setUp(self):
"""
TODO
"""
stadium = Stadium(name="test stadium")
stadium.save()
self.sector = Sector(stadium=stadium, letter="A", color="#00ff00",
rows=10, sits=10, price=Decimal("10.00"))
self.sector.save()
self.festival = Festival(stadium=stadium, name="test festival",
base_price=Decimal("10.00"))
self.festival.save()
start_night = datetime.now() + timedelta(days=50)
self.night = Night(festival=self.festival, datetime=start_night)
self.night.save()
for i in range(2):
band = Band(name="Test band %d" % i)
band.save()
self.bbn = BandByNight(band=band, night=self.night,
price=Decimal("5.00"))
self.bbn.save()
self.pt = PublicType(name="maxor", price=Decimal("10.00"))
self.pt.save()
self.discount = Discount(festival=self.festival, limit_days=30,
porcent=Decimal("10.00"))
self.discount.save()
self.ticket1 = Ticket(night=self.night, sector=self.sector, row=1,
sit=1, public_type=self.pt)
self.ticket1.save()
self.ticket2 = Ticket(night=self.night, sector=self.sector, row=1,
sit=2, public_type=self.pt)
self.ticket2.save()
self.sell_center = SellCenter(name="Test sell center")
self.sell_center.save()
self.sell_point = SellPoint(sell_center=self.sell_center)
self.sell_point.save()
self.sell = Sell(sell_point=self.sell_point)
self.sell.save()
ticket_sell = TicketSell(sell=self.sell, ticket=self.ticket1)
ticket_sell.save()
ticket_sell = TicketSell(sell=self.sell, ticket=self.ticket2)
ticket_sell.save()
def testMarkWasNotSelled(self):
"""
TODO
"""
self.assertEquals(True, self.ticket1.was_selled)
cancellation = Cancellation(ticket=self.ticket1)
cancellation.save()
self.assertEquals(False, self.ticket1.was_selled)
def testReSellCancelledTicket(self):
"""
TODO
"""
ticket = Ticket(night=self.night, sector=self.sector, row=1,
sit=5, public_type=self.pt)
ticket.save()
sell = Sell(sell_point=self.sell_point)
sell.save()
ticket_sell = TicketSell(sell=sell, ticket=ticket)
ticket_sell.save()
self.assertEquals(True, ticket.was_selled)
cancellation = Cancellation(ticket=ticket)
cancellation.save()
self.assertEquals(False, ticket.was_selled)
sell = Sell(sell_point=self.sell_point)
sell.save()
ticket_sell = TicketSell(sell=sell, ticket=ticket)
ticket_sell.save()
#.........这里部分代码省略.........