예제 #1
0
    def is_past_date(self):
        """Checks if the array of day, month and year strings represents a date in the past or the current date."""
        day = self.data[0]
        month = self.data[1]
        year = self.data[2]

        default_message = '{} was not the current date or in the past'.format(
            self.display_name)

        if not CommonValidator.is_past_date(day, month, year):
            self.validation_error_builder.add_error(self, default_message)

        return self
예제 #2
0
    def test_is_past_date_with_invalid_date(self):
        result = CommonValidator.is_past_date(INVALID_DAY, INVALID_MONTH,
                                              INVALID_YEAR)

        self.assertFalse(result)
예제 #3
0
    def test_is_past_date_with_future_date(self):
        result = CommonValidator.is_past_date(VALID_DAY, VALID_MONTH,
                                              VALID_FUTURE_DATE)

        self.assertFalse(result)
예제 #4
0
    def test_is_past_date_with_current_date(self):
        result = CommonValidator.is_past_date(CURRENT_DAY, CURRENT_MONTH,
                                              CURRENT_YEAR)

        self.assertTrue(result)
예제 #5
0
    def test_is_past_date_with_past_date(self):
        result = CommonValidator.is_past_date(VALID_DAY, VALID_MONTH,
                                              VALID_PAST_DATE)

        self.assertTrue(result)