Exemple #1
0
 def test_opening_bid(self):
     cli = make_auction(VickreyAuction)
     self.assertEqual([
         'Started auction of type: Vickrey', 'Please enter the opening bid:'
     ], cli.get_displayed())
     cli.type('30')
     self.assertIn('Opening bid is: 30', cli.get_displayed())
 def test_auction(self):
     cli = make_auction(BlindAuction)
     cli.type('30')
     cli.type('alice')
     cli.type('bob')
     cli.type('carol')
     cli.type(None)
     self.assertIn(
         'Opening bid is 30. alice bids:',
         cli.get_displayed()
     )
     cli.type(35)  # TODO: assert & bid
     self.assertEqual(
         [
             'Opening bid is 30. bob bids:'
         ],
         cli.get_displayed()
     )
     cli.type(50)
     self.assertEqual(
         [
             'Opening bid is 30. carol bids:'
         ],
         cli.get_displayed()
     )
     cli.type(40)
     self.assertEqual(
         'Winner is bob. Winning bid is 50.',
         cli.get_displayed()[-1]
     )
 def test_auction(self):
     cli = make_auction(EnglishAuction)
     cli.type('30')
     cli.type('alice')
     cli.type('bob')
     cli.type('carol')
     cli.type(None)
     # Round 1
     self.assertIn(
         'Standing bid is 30. alice bids:',
         cli.get_displayed()
     )
     cli.type(35)
     self.assertEqual(
         ['Standing bid is 35. bob bids:'],
         cli.get_displayed()
     )
     cli.type(40)
     self.assertEqual(
         ['Standing bid is 40. carol bids:'],
         cli.get_displayed()
     )
     cli.type(None)
     # Round 2
     self.assertEqual(
         ['Standing bid is 40. alice bids:'],
         cli.get_displayed()
     )
     cli.type(45)
     self.assertEqual(
         ['Standing bid is 45. bob bids:'],
         cli.get_displayed()
     )
     cli.type(None)
     self.assertEqual(
         ['Standing bid is 45. carol bids:'],
         cli.get_displayed()
     )
     cli.type(None)
     # Round 3
     self.assertEqual(
         ['Standing bid is 45. alice bids:'],
         cli.get_displayed()
     )
     cli.type(None)
     self.assertEqual(
         ['Standing bid is 45. bob bids:'],
         cli.get_displayed()
     )
     cli.type(None)
     self.assertEqual(
         ['Standing bid is 45. carol bids:'],
         cli.get_displayed()
     )
     cli.type(None)
     self.assertEqual(
         'Winner is alice. Winning bid is 45.',
         cli.get_displayed()[-1]
     )
Exemple #4
0
 def test_players(self):
     cli = make_auction(VickreyAuction)
     cli.type('30')
     self.assertIn('Enter bidder (enter nothing to move on):',
                   cli.get_displayed())
     cli.type('alice')
     self.assertEqual(['Enter bidder (enter nothing to move on):'],
                      cli.get_displayed())
     cli.type('bob')
     self.assertEqual(['Enter bidder (enter nothing to move on):'],
                      cli.get_displayed())
     cli.type('carol')
     self.assertEqual(['Enter bidder (enter nothing to move on):'],
                      cli.get_displayed())
     cli.type(None)
     self.assertIn('Bidders are: alice, bob, carol', cli.get_displayed())
 def test_echo(self):
     cli = make_auction(TestAuction)
     self.assertEqual(['give me your name'], cli.get_displayed())
     cli.type("hello")
     self.assertEqual(['hello'], cli.get_displayed())
     self.assertEqual([], cli.get_displayed())