예제 #1
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)
예제 #2
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)
예제 #3
0
 def test_4(self):
     """"tests to see if product is added to store"""
     p1 = Product("889", "Rodent of unusual size",
                  "when a rodent of the usual size just won't do", 33.45, 8)
     myStore = Store()
     myStore.add_product(p1)
     self.assertIn(p1, myStore._inventory)
예제 #4
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)
예제 #5
0
    def test_product(self):
        """
        tests thte basic functionality of the Product class
        """
        p1 = Product("889", "Rodent of unusual size",
                     "when a rodent of the usual size just won't do", 33.45, 8)
        self.assertEqual(p1.get_product_id(), "889")
        self.assertEqual(p1.get_title(), "Rodent of unusual size")
        self.assertEqual(p1.get_description(),
                         "when a rodent of the usual size just won't do")
        self.assertEqual(p1.get_price(), 33.45)
        self.assertEqual(p1.get_quantity_available(), 8)

        p1.decrease_quantity()

        self.assertEqual(p1.get_quantity_available(), 7)
예제 #6
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)
예제 #7
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")
예제 #8
0
    def test_store_get_product_from_id(self):
        """
        tests the basic functionality of the Store method get_product_from_id()
        """
        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, 3)
        p3 = Product("1000", "key-chain", "hold your keys", 0.99, 35)

        myStore = Store()

        myStore.add_product(p1)
        myStore.add_product(p2)
        myStore.add_product(p3)

        self.assertEqual(myStore.get_product_from_id("889"), p1)
        self.assertEqual(myStore.get_product_from_id("755"), p2)
        self.assertEqual(myStore.get_product_from_id("1000"), p3)
        self.assertEqual(myStore.get_product_from_id("10"), None)
예제 #9
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())
예제 #10
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)
예제 #11
0
    def test_store_product_search(self):
        """
        tests the basic functionality of the Store method product_search()
        """
        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, 3)
        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)

        myStore = Store()

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

        self.assertEqual(myStore.product_search("RoDeNt"),
                         ["001", "88", "889"])
예제 #12
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")
예제 #13
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)
예제 #14
0
 def test_2(self):
     """"tests to see if product quantity is not altered"""
     p1 = Product("889", "Rodent of unusual size",
                  "when a rodent of the usual size just won't do", 33.45, 8)
     self.assertAlmostEqual(p1.get_quantity_available(), 8)
예제 #15
0
    def test_4(self):
        fourth_product = Product(200, "Pencil", "Number 2 Pencil", 0.99, 1)
        product_price = fourth_product.get_price()

        self.assertEqual(product_price, 0.99)
예제 #16
0
 def test_real_product_profit(self):
     new_product = Product("Mock",50, 100)
     self.assertEqual(50, new_product.profit())