Example #1
0
    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)
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
    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)
Example #5
0
    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
Example #6
0
    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
Example #7
0
    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
Example #8
0
 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))
Example #9
0
 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))
Example #10
0
 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))
Example #11
0
 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))
Example #12
0
 def test_without_name(self):
     with self.assertRaises(TypeError):
         self.goods_list.add(
             GoodInfo(10, 10, '2020-12-30', '2020-12-30', 30))
Example #13
0
 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))
Example #14
0
 def test_ending(self):
     self.assertEqual(
         self.goods_list.get_ending()[0],
         GoodInfo('пирожки с картошкой', 30.0, 2, '2020-12-30',
                  '2020-12-30', 7))
Example #15
0
 def test_expensive(self):
     self.assertEqual(
         self.goods_list.get_expensive()[0],
         GoodInfo('рыба мороженая, Кета 1кг', 400.0, 5, '2020-12-30',
                  '2020-12-30', 90))