def testLatestAuctionStartedWithoutBidder(self):
     auction = Auction(Item("Van Gogh's painting", 1000))
     self.auction_house.add_auction(auction)
     auction.start()
     logging.info(
         self.auction_house.latest_auction_by_item_name(
             "Van Gogh's painting"))
 def testLatestAuctionStartedWithBidder(self):
     auction = Auction(Item("Van Gogh's painting", 1000))
     self.auction_house.add_auction(auction)
     auction.start()
     guillaume = Participant("Guillaume")
     guillaume.bid(auction, 1001)
     logging.info(self.auction_house.latest_auction_by_item_name("Van Gogh's painting"))
 def testLatestAuctionStartedWithBidder(self):
     auction = Auction(Item("Van Gogh's painting", 1000))
     self.auction_house.add_auction(auction)
     auction.start()
     guillaume = Participant("Guillaume")
     guillaume.bid(auction, 1001)
     logging.info(
         self.auction_house.latest_auction_by_item_name(
             "Van Gogh's painting"))
Beispiel #4
0
def main():
    auction_house = AuctionHouse()

    guillaume = Participant("Guillaume")
    antonin = Participant("Antonin")

    painting_name = "Van Gogh's painting"
    painting = Item(painting_name, 1000)
    auction_painting = Auction(painting)

    auction_house.add_auction(auction_painting)
    # should fail - auction already added
    auction_house.add_auction(auction_painting)

    # auction has not been started yet
    guillaume.bid(auction_painting, 101)

    auction_painting.start()

    guillaume.bid(auction_painting, 101)
    antonin.bid(auction_painting, 999)
    # guillaume should bid more than 999
    guillaume.bid(auction_painting, 102)
    guillaume.bid(auction_painting, 1002)

    auction_painting.stop()

    logging.info(auction_house.latest_auction_by_item_name(painting_name))

    # should fail
    Auction(painting)

    # should fail
    auction_painting.start()
 def setUp(self):
     self.auction = Auction(Item("Van Gogh's painting", 1000))
class TestAuction(unittest.TestCase):
    def setUp(self):
        self.auction = Auction(Item("Van Gogh's painting", 1000))

    def tearDown(self):
        self.auction = None

    # Start an auction
    # OK Test
    def testStart(self):
        self.auction.start()
        self.assertTrue(self.auction.is_started)

    # Stop an auction which was not started
    # KO Test
    def testStopFail(self):
        self.auction.stop()
        self.assertFalse(self.auction.is_started)
        self.assertFalse(self.auction.has_failed)
        self.assertIsNone(self.auction.highest_bid)

    # Stop an auction without bids
    # KO Test
    def testStopAuctionFailed(self):
        self.auction.start()
        self.auction.stop()
        self.assertFalse(self.auction.is_started)
        self.assertTrue(self.auction.has_failed)
        self.assertIsNone(self.auction.highest_bid)

    # Stop an auction with a bid's price higher than
    # the reserved price.
    # OK Test
    def testStopAuctionSuccess(self):
        self.auction.start()
        guillaume = Participant("Guillaume")

        guillaume.bid(self.auction, 1001)

        self.auction.stop()
        self.assertFalse(self.auction.is_started)
        self.assertFalse(self.auction.has_failed)
 def testAddAuctionFailure(self):
     auction = Auction(Item("Van Gogh's painting", 1000))
     self.auction_house.add_auction(auction)
     self.auction_house.add_auction(auction)
     self.assertListEqual(self.auction_house.auctions, [auction])
 def testLatestAuctionStartedWithoutBidder(self):
     auction = Auction(Item("Van Gogh's painting", 1000))
     self.auction_house.add_auction(auction)
     auction.start()
     logging.info(self.auction_house.latest_auction_by_item_name("Van Gogh's painting"))