Esempio n. 1
0
 def testLastWeekDay(self):
     """should return yesterday or friday if today is monday"""
     monday = datetime.date(2013, 05, 20)
     friday = datetime.date(2013, 05, 17)
     today = datetime.date(2013, 05, 22)
     yesterday = datetime.date(2013, 05, 21)
     self.assertEquals(yesterday, DateHelper.get_last_week_day(today), 'if not monday, should return yesterday')
     self.assertEquals(friday, DateHelper.get_last_week_day(monday), 'if monday should return last friday')
Esempio n. 2
0
 def testLastWeekDay(self):
     """should return yesterday or friday if today is monday"""
     monday = datetime.date(2013, 05, 20)
     friday = datetime.date(2013, 05, 17)
     today = datetime.date(2013, 05, 22)
     yesterday = datetime.date(2013, 05, 21)
     self.assertEquals(yesterday, DateHelper.get_last_week_day(today),
                       'if not monday, should return yesterday')
     self.assertEquals(friday, DateHelper.get_last_week_day(monday),
                       'if monday should return last friday')
Esempio n. 3
0
    def get_start_and_end_date(self, dates):
        """
        Get a tuple with start and end dates. Default is none for end date, and last week-day for start_date

        :param dates:list of dates
        :return:tuple (start,end)
        """
        date_objects = [dateutil.parser.parse(d, dayfirst=True) for d in dates]

        # default values is None for end_date and last week-day for start_date
        start_date = None
        end_date = None
        if date_objects is None or len(date_objects) == 0:
            date_objects.append(DateHelper.get_last_week_day())

        if len(date_objects) == 1:
            start_date = ZebraHelper.zebra_date(date_objects[0])
        if len(date_objects) == 2:
            start_date = ZebraHelper.zebra_date(min(date_objects))
            end_date = ZebraHelper.zebra_date(max(date_objects))

        return (start_date, end_date)
Esempio n. 4
0
    def get_start_and_end_date(self, dates):
        """
        Get a tuple with start and end dates. Default is none for end date, and last week-day for start_date

        :param dates:list of dates
        :return:tuple (start,end)
        """
        date_objects = [dateutil.parser.parse(d, dayfirst=True) for d in dates]

        # default values is None for end_date and last week-day for start_date
        start_date = None
        end_date = None
        if date_objects is None or len(date_objects) == 0:
            date_objects.append(DateHelper.get_last_week_day())

        if len(date_objects) == 1:
            start_date = ZebraHelper.zebra_date(date_objects[0])
        if len(date_objects) == 2:
            start_date = ZebraHelper.zebra_date(min(date_objects))
            end_date = ZebraHelper.zebra_date(max(date_objects))

        return (start_date, end_date)
Esempio n. 5
0
 def testStartAndEndDates(self):
     """should return a tuple with start and end dates as zebra dates"""
     base_command = BaseCommand()
     self.assertEquals(
         ('2013-05-22', None),
         base_command.get_start_and_end_date(['2013.05.22']),
         'test input format 1'
     )
     self.assertEquals(
         ('2013-05-22', None),
         base_command.get_start_and_end_date(['22.05.2013']),
         'test input format 2'
     )
     self.assertNotEquals(
         (None, None),
         base_command.get_start_and_end_date([]),
         'if no date is specified, date_start should not be None'
     )
     last_week_day = ZebraHelper.zebra_date(DateHelper.get_last_week_day())
     self.assertEquals(
         (last_week_day, None),
         base_command.get_start_and_end_date([]),
         'if no date is specified, date_start should be last week day'
     )