def test_add_without_name(self): """ Function test product buy without name """ good = GoodInfo("", "30", "40", "2020-12-30", "14", "2020-12-30") check_product_data = self.database.add(good) self.assertFalse(check_product_data)
def test_add_with_negative_amount(self): """ Function test add with negative amount """ good = GoodInfo("яйцо 1 кат.", "30", "-40", "2020-12-30", "14", "2020-12-30") check_product_data = self.database.add(good) self.assertFalse(check_product_data)
def test_add_with_end_shelf_life(self): """ Function test add with end shelf life """ good = GoodInfo("яйцо 1 кат.", "-30", "40", "2020-12-1", "3", "2020-12-1") check_product_data = self.database.add(good) self.assertFalse(check_product_data)
def test_add_with_not_right_shelf_life(self): """ Function test product buy not right shelf life """ good = GoodInfo("яйцо 1 кат.", "-30", "40", "2020-12-30", "-14", "2020-12-30") check_product_data = self.database.add(good) self.assertFalse(check_product_data)
def form_cheapset_list_goods(self): """ Function form list with cheapset goods :return: function return GoodInfoList with most cheapset sort goods """ self.database.truncate_all_tables() list_with_object_cheapset_test = [ GoodInfo('макароны Макфа,рожки', '30', '7', '2020-12-30', '360', '2020-12-30'), GoodInfo('макароны Макфа,спагетти', '30', '10', '2020-12-30', '360', '2020-12-30') ] for good in list_with_object_cheapset_test: self.database.add(good) most_cheapset_test_list = self.database.get_all_goods() return most_cheapset_test_list
def form_expensive_list_goods(self): """ Function form list with most expensive goods :return: function return GoodInfoList with most expensive sort goods """ self.database.truncate_all_tables() self.database.add( GoodInfo("рыба мороженая, Кета 1кг", "400", "5", "2020-12-30", "90", "2020-12-30")) most_expensive_test_list = self.database.get_all_goods() return most_expensive_test_list
def form_ending_list_goods(self): """ Function form list with ending goods :return: function return GoodInfoList with most ending sort goods """ self.database.truncate_all_tables() list_with_objects_ending_test = [ GoodInfo('вермишель Макфа 1кг', '45', '2', '2020-12-30', '720', '2020-12-30') ] for good in list_with_objects_ending_test: self.database.add(good) list_with_ending_goods = self.database.get_all_goods() return list_with_ending_goods
def test_zero_count(self): self.goods_list.add( GoodInfo('хлеб', 10, 0, '2020-12-30', '2020-12-30', 30)) self.assertNotEqual( self.goods_list[-1], GoodInfo('хлеб', 10, 0, '2020-12-30', '2020-12-30', 30))
def test_add_expired(self): self.goods_list.add( GoodInfo('хлеб', 10, 10, '2020-12-20', '2020-12-30', 3)) self.assertNotEqual( self.goods_list[-1], GoodInfo('хлеб', 10, 10, '2020-12-20', '2020-12-30', 3))
def test_negative_cost(self): self.goods_list.add( GoodInfo('хлеб', -10, 10, '2020-12-30', '2020-12-30', 30)) self.assertNotEqual( self.goods_list[-1], GoodInfo('хлеб', -10, 10, '2020-12-30', '2020-12-30', 30))
def test_wrong_expiration(self): self.goods_list.add( GoodInfo('хлеб', 10, 10, '2020-12-30', '2020-12-30', -30)) self.assertNotEqual( self.goods_list[-1], GoodInfo('хлеб', 10, 10, '2020-12-30', '2020-12-30', -30))
def test_without_name(self): with self.assertRaises(TypeError): self.goods_list.add( GoodInfo(10, 10, '2020-12-30', '2020-12-30', 30))
def test_sort(self): self.assertEqual( self.goods_list.sort_goods('name')[0], GoodInfo('Чай зеленый Lipton 10 пак.', 60.0, 20, '2020-12-30', '2020-12-30', 1080))
def test_ending(self): self.assertEqual( self.goods_list.get_ending()[0], GoodInfo('пирожки с картошкой', 30.0, 2, '2020-12-30', '2020-12-30', 7))
def test_expensive(self): self.assertEqual( self.goods_list.get_expensive()[0], GoodInfo('рыба мороженая, Кета 1кг', 400.0, 5, '2020-12-30', '2020-12-30', 90))