Esempio n. 1
0
 def test_convert_date_to_str(self):
     date_check = '2021-03-02'
     date_check2 = datetime.date(2021, 3, 2)
     date = Date().convert_date_to_str(date_check)
     date2 = Date().convert_date_to_str(date_check2)
     self.assertEqual(date_check, date)
     self.assertEqual(date_check, date2)
Esempio n. 2
0
    def test_get_query_used_tmpls(self):
        date = Date().get_date(self.month)
        check_query: str = f"SELECT template_id FROM new_message WHERE (day>='2021-02-01' AND  " \
               f"day<'2021-03-01')  GROUP BY template_id ORDER BY template_id"
        query = self.tmpls.get_query_used_tmpls(month=date)

        self.assertEqual(check_query, query)
Esempio n. 3
0
 def test_get_query_used_tmpls2(self):
     date = Date().get_date(self.month)
     ext_query = "oa='7757'"
     query = self.tmpls.get_query_used_tmpls(month=date,
                                             ext_query=ext_query)
     check_query = f"SELECT template_id FROM new_message WHERE (day>='{2021:04d}-{2:02d}-01' AND  " \
            f"day<'{2021:02d}-{3:02d}-01') AND (oa='7757') GROUP BY template_id ORDER BY template_id"
     self.assertEqual(check_query, query)
Esempio n. 4
0
 def test_get_days(self):
     date_obj = Date('2020-03')
     days = date_obj.get_current_month_days(True)
     self.assertEqual(31, days)
     date_obj2 = Date('2021-02')
     days2 = date_obj2.get_current_month_days(True)
     self.assertEqual(28, days2)
Esempio n. 5
0
 def test_get_next_month2(self):
     date_obj = Date('2020-03-11', False)
     next_date = date_obj.get_next_date()
     self.assertEqual(2020, next_date.year)
     self.assertEqual(4, next_date.month)
     self.assertEqual(11, next_date.day)
     date_obj = Date('2020-03-11', True)
     next_date2 = date_obj.get_next_date()
     self.assertEqual(2020, next_date2.year)
     self.assertEqual(4, next_date2.month)
     self.assertEqual(1, next_date2.day)
Esempio n. 6
0
    def test_get_date_list(self):
        result = Date().get_date_list('2021-04-01', '2021-04-03')
        self.assertEqual(2, len(result))
        result2 = Date().get_date_list('2021-03-28', '2021-04-03')
        self.assertEqual(6, len(result2))
        result3 = Date().get_date_list('2021-03-28', '2021-03-29')
        self.assertEqual(1, len(result3))
        result4 = Date().get_date_list('2021-03-28', '2021-03-28')
        self.assertEqual(1, len(result4))

        result5 = Date().get_date_list('2021-03-28 00:00:00',
                                       '2021-03-28 00:01:30', 'hour')
        self.assertEqual(1, len(result5))
        result6 = Date().get_date_list('2021-03-28 00:00:00',
                                       '2021-03-28 00:01:30', 'min')
        self.assertEqual(2, len(result6))
        result7 = Date().get_date_list('2021-03-28 00:00:00',
                                       '2021-03-28 05:01:30', 'hour')
        self.assertEqual(6, len(result7))
Esempio n. 7
0
 def test_default_date(self):
     date_obj = Date(self.date)
     self.assertEqual(self.date.year, date_obj.date.year)
     self.assertEqual(self.date.month, date_obj.date.month)
     date_obj = Date(self.date, True)
     self.assertEqual(1, date_obj.date.day)
Esempio n. 8
0
 def test_get_prev_month2(self):
     date_obj = Date('2020-03-06')
     prev_date = date_obj.get_prev_date(first_day=True)
     self.assertEqual(2020, prev_date.year)
     self.assertEqual(2, prev_date.month)
     self.assertEqual(1, prev_date.day)
Esempio n. 9
0
 def test_get_prev_month(self):
     date_obj = Date('2020-03')
     prev_date = date_obj.get_prev_date()
     self.assertEqual(2020, prev_date.year)
     self.assertEqual(2, prev_date.month)
Esempio n. 10
0
 def test_get_next_month3(self):
     date_obj = Date('2020-02')
     next_date = date_obj.get_next_date()
     self.assertEqual(2020, next_date.year)
     self.assertEqual(3, next_date.month)
     self.assertEqual(1, next_date.day)
Esempio n. 11
0
 def test_get_next_month(self):
     date_obj = Date('2020-03')
     next_date = date_obj.get_next_date()
     self.assertEqual(2020, next_date.year)
     self.assertEqual(4, next_date.month)
Esempio n. 12
0
 def test_default_dtring_date3(self):
     date_obj = Date('2020-02-21', True)
     self.assertEqual(2020, date_obj.date.year)
     self.assertEqual(2, date_obj.date.month)
     self.assertEqual(1, date_obj.date.day)