コード例 #1
0
ファイル: test_user.py プロジェクト: orsaada/ecommerce-site
    def test_change_details_of_product(self):
        user1 = User("amir", 1)
        user1.identifier = 0
        user1.username = "******"
        user1.password = "******"
        user1.state = State.STORE_OWNER
        user1.is_logged_in = True

        store1 = Store("mega", 1, "123123", None, None)
        store1.store_number = 1

        product1 = Product('chocholate', 'Food', ['Food', 'Sweet'], 10)
        product1.catalog_number = 1

        store1.owners = [0]
        store1.add_new_product(product1)

        Ecommerce.get_instance().subscribers = [user1]
        Ecommerce.get_instance().stores = [store1]

        self.assertTrue(
            user1.change_details_of_product(1, "name", "whiteChocholate").val,
            "need return True")
        self.assertFalse(
            user1.change_details_of_product(2, "name", "whiteChocholate").val,
            "need return False")
コード例 #2
0
ファイル: test_user.py プロジェクト: orsaada/ecommerce-site
 def test_search_product(self):  #ok
     store1 = Store("ramiLevi", 0, "123123", None, None)
     store1.store_number = 0
     product1 = Product('Apple', 'Fruits', ['Food', 'Fruit', 'Apple'], 5)
     product1.catalog_number = 0
     store1.add_new_product(product1)
     Ecommerce.get_instance().stores = [store1]
     self.assertEqual(len(User.search_product("name", "Apple").val), 1,
                      'bad')
コード例 #3
0
ファイル: test_user.py プロジェクト: orsaada/ecommerce-site
 def test_add_to_cart(self):  #ok
     user1 = User("amir", 12)
     product1 = Product('chocholate', 'Food', ['Food', 'Sweet'], 10)
     product1.catalog_number = 1
     store1 = Store("ramiLevi", 0, "123123", None, None)
     store1.add_new_product(product1)
     Ecommerce.get_instance().stores = [store1]
     store1.inc_product_amount(1, 5)
     self.assertTrue(user1.add_to_cart(1).val, "need return True")
     self.assertFalse(user1.add_to_cart(9).val, "need return False")
コード例 #4
0
ファイル: test_user.py プロジェクト: orsaada/ecommerce-site
 def test_remove_from_cart(self):  #ok
     user1 = User("amir", 32)
     user1.identifier = 1
     user1.state = State.STORE_OWNER
     product1 = Product('chocholate', 'Food', ['Food', 'Sweet'], 10)
     product1.catalog_number = 1
     store1 = Store("ramiLevi", 0, "123123", None, None)
     store1.store_number = 0
     store1.supervisor = 1
     store1.add_new_product(product1)
     store1.owners = [user1.identifier]
     Ecommerce.get_instance().stores = [store1]
     self.assertTrue(user1.remove_product(0, 1).val, "need return True")
     self.assertFalse(user1.remove_product(0, 1).val, "need return False")
コード例 #5
0
ファイル: test_user.py プロジェクト: orsaada/ecommerce-site
 def test_remove_product(self):  #ok
     user1 = User("amir", 12)
     user1.identifier = 0
     store1 = Store("mega", 0, "456456", None, None)
     store1.store_number = 1
     product1 = Product('chocholate', 'Food', ['Food', 'Sweet'], 10)
     product1.catalog_number = 1
     store1.add_new_product(product1)
     Ecommerce.get_instance().stores = [store1]
     user1.state = State.GUEST
     self.assertFalse(user1.remove_product(1, 1).val, "need return False")
     user1.state = State.STORE_OWNER
     self.assertTrue(user1.remove_product(1, 1), "need return True")
     self.assertFalse(user1.remove_product(1, 10).val, "need return False")
コード例 #6
0
ファイル: test_user.py プロジェクト: orsaada/ecommerce-site
 def test_inc_product_amount(self):  #ok
     user1 = User("amir", 13)
     user1.identifier = 0
     store1 = Store("ramiLevi", 0, "123123", None, None)
     store1.store_number = 0
     product1 = Product('Banana', 'Fruits', ['Food', 'Fruit', 'Apple'], 5)
     product1.catalog_number = 0
     store1.add_new_product(product1)
     Ecommerce.get_instance().stores = [store1]
     user1.state = State.GUEST
     self.assertFalse(
         user1.inc_product_amount(0, 0, 3).val, "need return False")
     user1.state = State.STORE_OWNER
     self.assertTrue(
         user1.inc_product_amount(0, 0, 3).val, "need return True")
     self.assertFalse(
         user1.inc_product_amount(100, 0, 3).val, "need return False")
     self.assertFalse(
         user1.inc_product_amount(0, 10, 3).val, "need return False")