Ejemplo n.º 1
0
    def test_1(self):
        first_product = Product(1, "Lemon", "Fresh lemons", 3, 10)
        first_customer = Customer("Mohammad", 31343, True)
        first_store = Store()

        test_bool = first_customer.is_premium_member()
        self.assertTrue(test_bool)
Ejemplo n.º 2
0
    def test_5(self):
        p1 = Product("111", "Orange Juice", "Off Brand OJ with pulp", 3.99, 3)
        c1 = Customer("Jun", "ABC", False)
        myStore = Store()
        myStore.add_product(p1)
        myStore.add_member(c1)
        myStore.add_product_to_member_cart("111", "ABC")
        result = myStore.check_out_member("ABC")

        self.assertFalse(c1.is_premium_member())
Ejemplo n.º 3
0
    def test_3(self):
        third_test_customer_1 = Customer("FIRST CUSTOMER", 12345, True)
        third_test_customer_2 = Customer("SECOND CUSTOMER", 23456, False)
        third_test_customer_3 = Customer("THIRD CUSTOMER", 34567, False)

        third_store = Store()

        third_store.add_member(third_test_customer_1)
        third_store.add_member(third_test_customer_2)
        third_store.add_member(third_test_customer_3)

        test_3 = third_store.lookup_member_from_id(23456)
        self.assertIs(test_3, "SECOND CUSTOMER")
Ejemplo n.º 4
0
    def test_store_get_member_from_id(self):
        """
        tests the basic functionality of the Store method get_member_from_id()
        """
        c1 = Customer("Yinsheng", "QWF", False)
        c2 = Customer("Alan", "ABC", True)
        c3 = Customer("Kirk", "EEF", True)

        myStore = Store()

        myStore.add_member(c1)
        myStore.add_member(c2)
        myStore.add_member(c3)

        self.assertEqual(myStore.get_member_from_id("QWF"), c1)
        self.assertEqual(myStore.get_member_from_id("ABC"), c2)
        self.assertEqual(myStore.get_member_from_id("EEF"), c3)
        self.assertEqual(myStore.get_member_from_id("DLL"), None)
Ejemplo n.º 5
0
 def test_4(self):
     with self.assertRaises(InvalidCheckoutError):
         p1 = Product("111", "Orange Juice", "Off Brand OJ with pulp", 3.99, 3)
         c1 = Customer("Jun", "ABC", True)
         myStore = Store()
         myStore.add_product(p1)
         myStore.add_member(c1)
         myStore.add_product_to_member_cart("111", "ABC")
         result = myStore.check_out_member("ABD")
Ejemplo n.º 6
0
    def test_2(self):

        p1 = Product("111", "Orange Juice", "Off Brand OJ with pulp", 3.99, 3)
        c1 = Customer("Jun", "ABC", True)
        myStore = Store()
        myStore.add_product(p1)
        myStore.add_member(c1)
        myStore.add_product_to_member_cart("111", "ABC")
        result = myStore.check_out_member("ABC")

        self.assertAlmostEqual(result,3.99)
Ejemplo n.º 7
0
 def test_1(self):
     """"tests to see if product not added to store remains not in store"""
     p1 = Product("889", "Rodent of unusual size",
                  "when a rodent of the usual size just won't do", 33.45, 8)
     p2 = Product("48", "Balding Spray",
                  "when a bald spot of the usual size just won't do",
                  330.45, 2)
     c1 = Customer("Yinsheng", "QWF", False)
     myStore = Store()
     myStore.add_product(p1)
     myStore.add_member(c1)
     self.assertNotIn(p2, myStore._members)
Ejemplo n.º 8
0
 def test_3(self):
     p1 = Product("112", "Milk", "2% Milk fat", 2.00, 7)
     p2 = Product("113", "Toilet Paper", "To wipe away the coronavirus", 100.00, 7)
     c1 = Customer("Jun", "ABC", True)
     myStore = Store()
     myStore.add_product(p1)
     myStore.add_product(p2)
     myStore.add_member(c1)
     myStore.add_product_to_member_cart("112", "ABC")
     myStore.add_product_to_member_cart("113", "ABC")
     result = myStore.check_out_member("ABC")
     self.assertAlmostEqual(result,102.00)
Ejemplo n.º 9
0
    def test_5(self):
        fifth_test_customer = Customer("Robot", 3000, True)

        fifth_test_product_1 = Product(2345, "Box of Apples", "Box of six green apples", 1, 1)

        fifth_store = Store()

        fifth_store.add_member(fifth_test_customer)
        fifth_store.add_product(fifth_test_product_1)

        result = fifth_store.add_product_to_member_cart(2345, 3000)

        self.assertEqual(result, "Product added to cart")
Ejemplo n.º 10
0
    def test_assert_raises_InvalidCheckoutError(self):
        """
        tests the basic functionality of the InvalidCheckoutError class and its appropriate use in the checkout_member()
        method
        """
        with self.assertRaises(InvalidCheckoutError):
            c1 = Customer("Yinsheng", "QWF", False)
            myStore = Store()
            myStore.add_member(c1)
            myStore.check_out_member("NOTAVALIDCUSTID")

        with self.assertRaises(InvalidCheckoutError):
            myStore = Store()
            myStore.check_out_member("NOTAVALIDCUSTID")
Ejemplo n.º 11
0
    def test_2(self):
        second_test_product_1 = Product(121, "Banana", "Yellow Banana", 2.50, 10)
        second_test_product_2 = Product(220, "Mango", "Tropical Mango", 4, 5)
        second_test_product_3 = Product(5778, "Doritos", "Cool Ranch Doritos", 3.99, 3)
        second_test_customer = Customer("Rondo", 778304, False)
        second_store = Store()

        # Add Customer to store
        second_store.add_member(second_test_customer)

        # Add products to cart
        second_store.add_product(second_test_product_1)
        second_store.add_product(second_test_product_2)
        second_store.add_product(second_test_product_3)

        total_price = second_store.check_out_member(778304)
        self.assertAlmostEqual(total_price, 11.2243)
Ejemplo n.º 12
0
    def test_checkout_sum(self):
        """
        tests basic functionality of the Store method check_out_member()
        """
        p1 = Product("889", "Rodent of unusual size",
                     "when a rodent of the usual size just won't do", 33.45, 8)
        p2 = Product("755", "Plunger", "dislodge clogs", 15.00, 1)
        p3 = Product("1000", "key-chain", "hold your keys", 0.99, 35)
        p4 = Product("88", "rat trap", "traps rodents", 3.99, 50)
        p5 = Product("001", "mouse pad", "not a RODENT's house", 9.95, 20)
        p6 = Product("002", "remote conrol",
                     "you and your signficant other will fight for it", 14.50,
                     0)

        c1 = Customer("Yinsheng", "QWF", True)
        myStore = Store()

        myStore.add_member(c1)

        myStore.add_product(p1)
        myStore.add_product(p3)
        myStore.add_product(p4)
        myStore.add_product(p2)
        myStore.add_product(p5)
        myStore.add_product(p6)

        myStore.add_product_to_member_cart("88", "QWF")
        myStore.add_product_to_member_cart("002", "QWF")
        myStore.add_product_to_member_cart("889", "QWF")
        myStore.add_product_to_member_cart("889", "QWF")
        myStore.add_product_to_member_cart("755", "QWF")
        myStore.add_product_to_member_cart("755", "QWF")
        myStore.add_product_to_member_cart("1000", "QWF")
        myStore.add_product_to_member_cart("001", "QWF")
        myStore.add_product_to_member_cart("002", "QWF")
        myStore.add_product_to_member_cart("002", "QWF")

        self.assertAlmostEqual(myStore.check_out_member("QWF"), 96.83)
Ejemplo n.º 13
0
 def test_5(self):
     """"tests to see if get account ID returns correct account ID"""
     c1 = Customer("Yinsheng", "QWF", False)
     result = c1.get_account_ID()
     self.assertIs(result, "QWF")
Ejemplo n.º 14
0
 def test_3(self):
     """"tests to see if customer is added to Store members"""
     c1 = Customer("Yinsheng", "QWF", False)
     myStore = Store()
     myStore.add_member(c1)
     self.assertIn(c1, myStore._members)
Ejemplo n.º 15
0
    def test_customer(self):
        """
        tests the basic functionality of the Customer class
        """
        c1 = Customer("Yinsheng", "QWF", False)

        self.assertEqual(c1.get_name(), "Yinsheng")
        self.assertEqual(c1.get_customer_id(), "QWF")
        self.assertFalse(c1.is_premium_member())

        c1.add_product_to_cart("101")
        c1.add_product_to_cart("889")

        self.assertDictEqual(c1.get_cart(), {"889": 1, "101": 1})

        c1.add_product_to_cart("101")
        c1.add_product_to_cart("889")

        self.assertDictEqual(c1.get_cart(), {"101": 2, "889": 2})

        c1.empty_cart()

        self.assertEqual(c1.get_cart(), {})