def test_delete_list_consumption(self):
     for _ in range(2):
         add_example_consumption(session)
     consumptions = session.query(Consumption).all()
     Consumption.delete_list_consumption(session, consumptions)
     answer = session.query(Consumption).all()
     self.assertEqual(answer, [])
 def test_repr(self):
     add_example_consumption(session)
     expected = f"<Consumption('{example_consumption['id']}', " \
         f"'{example_consumption['user_id']}', '{example_consumption['category_id']}', " \
         f"'{example_consumption['amount_money']}', '{example_consumption['time_creation']}')>"
     consumption = session.query(Consumption).get(1)
     self.assertEqual(repr(consumption), expected)
 def test_exist_category(self):
     add_example_limit(session)
     add_example_category_consumption(session)
     add_example_consumption(session)
     limit = session.query(Limit).get(1)
     expected = f"{TypeLimit.text_type(example_limit['type_limit']).title()} " \
                f"{example_category_consumption['category']} - {example_limit['amount_money']} р."
     actual = text_limit(session, limit)
     self.assertEqual(expected, actual)
Exemple #4
0
 def test_make_text_week_results(self):
     now = datetime.datetime(2020, 1, 12, 12, 30, 00)
     add_example_user(session)
     add_example_consumption(session)
     user = session.query(User).get(1)
     actual = make_text_week_results(session, now, user)
     expected = 'За прошедшую неделю вы потратили <b>{} рублей</b>.'.format(
         example_consumption['amount_money'])
     self.assertEqual(expected, actual)
    def test_make_text_delete_transaction(self):
        add_example_category_consumption(session)
        add_example_consumption(session)

        consumption = session.query(Consumption).get(1)
        expected = f"Вы уверены, что хотите удалить расход в размере <b>{example_consumption['amount_money']} " \
            f"рублей</b> категории <b>{example_category_consumption['category']}</b>, созданный в " \
            f"<b>{consumption.get_str_time_creation()}</b>?"
        self.assertEqual(self.deleter.make_text_delete_transaction(session),
                         expected)
Exemple #6
0
 def test_exist_transactions(self):
     now = datetime.datetime(2020, 1, 22, 10, 10)
     add_example_user(session)
     add_example_category_consumption(session)
     add_example_category_earning(session)
     add_example_consumption(session, now)
     add_example_earning(session, now)
     expected =  f"Информация на 22.01.2020 10:10, Среда\n\n" \
                 f"<b>Расходы:</b>\n" \
         f"{example_category_consumption['category']} - {example_consumption['amount_money']} р.\n\n" \
                 f"<b>Доходы:</b>\n" \
         f"{example_category_earning['category']} - {example_earning['amount_money']} р.\n\n" \
                 f"<b>Всего:</b>\n" \
         f"Доход: {example_earning['amount_money']}\n" \
         f"Расход: {example_consumption['amount_money']}\n\n" \
                 f"Хорошего дня!"
     user = session.query(User).get(1)
     actual = make_text_today(session, now, user)
     self.assertEqual(actual, expected)
 def test_get_time_creation(self):
     add_example_consumption(session)
     consumption = session.query(Consumption).get(1)
     answer = consumption.get_str_time_creation()
     expected = '10.01.2020, 12:30'
     self.assertEqual(answer, expected)
 def test_query_consumption(self):
     add_example_consumption(session)
     expected = [Consumption(id=1, user_id=1, category_id=1, amount_money=1)]
     consumptions = session.query(Consumption).all()
     self.assertEqual(consumptions, expected)
 def test_delete_transaction(self):
     add_example_consumption(session)
     self.deleter.delete_transaction(session)
     answer = session.query(Consumption).get(1)
     expected = None
     self.assertEqual(answer, expected)