예제 #1
0
 def setUp(self):
     self.auction_event = Auction_event()
     self.user = User(Name("Patrick", "", "Wu"),
                      Card("1234567890123456", "123", 2099, 12),
                      Addr("Room A, Rd B", "London", "UK", "WC1E 6BT"))
     self.item1 = Item("iPhone XS Max Space Grey", "A2104 256G", 6000)
     self.item2 = Item("Google Pixel 3 XL", "G013C 64G", 5000)
예제 #2
0
def main():
    auction = Auction(Item("iPhone XS Max", "iPhone A2104 256G", 6000))
    user = User(Name("Patrick", "", "Wu"), Card("1234567890", "123", 2099, 12),
                Addr("Room A, Road B", "London", "UK", "WC1E 6BT"))
    auction.start()
    user.bid(auction, 6010)
    user.bid(auction, 6020)
    auction.stop()
예제 #3
0
def users_handler():
    if request.method == 'GET':
        return jsonify(users)
    else:
        first_name = request.form.get('first_name')
        middle_name = request.form.get('middle_name')
        last_name = request.form.get('last_name')
        card_number = request.form.get('card_number')
        cvc = request.form.get('cvc')
        expiry_year = request.form.get('expiry_year')
        expiry_month = request.form.get('expiry_month')
        addr_detail = request.form.get('addr_detail')
        city = request.form.get('city')
        postal = request.form.get('postal')
        new_user = User(Name(first_name, middle_name, last_name),
                        Card(card_number, cvc, expiry_year, expiry_month),
                        Addr(addr_detail, city, postal))
        users.append(new_user)
        return jsonify(new_user.id)
예제 #4
0
 def setUp(self):
     self.auction = Auction(Item("iPhone XS Max", "iPhone A2104 256G",
                                 6000))
     self.user = User(Name("Patrick", "", "Wu"),
                      Card("1234567890123456", "000", 2099, 12),
                      Addr("Room A, Road B", "London", "UK", "WC1E 6BT"))
예제 #5
0
 def testValidCard(self):
     self.card = Card("1234567890123456", "123", 2099, 7)
     self.assertEqual(self.card.number, "1234567890123456")
     self.assertEqual(self.card.cvc, "123")
     self.assertEqual(self.card.expiry_year, 2099)
     self.assertEqual(self.card.expiry_month, 7)
예제 #6
0
 def testInvalidCard(self):
     with self.assertRaises(Exception) as context:
         self.card = Card("1234567890123456", "123", 2008, 9)
     self.assertTrue("Card invalid" in str(context.exception))
예제 #7
0
 def testUnparsableDate(self):
     with self.assertRaises(Exception) as context:
         self.card = Card("1234567890123456", "123", "aabb", "cd")
     self.assertTrue("Couldn't parse input expiry year or month" in str(
         context.exception))
예제 #8
0
 def testWrongCVC(self):
     with self.assertRaises(Exception) as context:
         self.card = Card("1234567890123456", "aab", 2020, 11)
     self.assertTrue(
         "Card CVC should 3 digits long" in str(context.exception))
예제 #9
0
 def testWrongCardNumber(self):
     with self.assertRaises(Exception) as context:
         self.card = Card("1234", "123", 2020, 11)
     self.assertTrue(
         "Card number should be 16 digits long" in str(context.exception))