Example #1
0
    def test_datetime_string_well_formed(self):
        """
        In this test case, a well formed datetime string has been provided.

        We expect that this should be successfully parsed, and the corresponding path components computed.

        :return:
        """

        datetime_string = '2020:01:15 18:00:41'
        expected_result = ['2020', '01 - January', '15']
        actual_result = sort_image_files.compute_hierarchical_path_components(
            datetime_string)

        self.assertEqual(actual_result, expected_result)
Example #2
0
    def test_datetime_string_empty(self):
        """
        In this test case, an empty datetime string is provided. Clearly this is not a proper date.

        We expect this to be caught, and for an empty list to be returned.

        :return:
        """

        datetime_string = ''
        expected_result = []
        actual_result = sort_image_files.compute_hierarchical_path_components(
            datetime_string)

        self.assertEqual(actual_result, expected_result)
Example #3
0
    def test_datetime_string_malformed_month_too_short(self):
        """
        In this test case, a malformed datetime string has been provided, where the month portion of the date is
        invalid (it has only one digit, rather than two).

        We expect this to be caught, and for an empty list to be returned.

        :return:
        """

        datetime_string = '2020:1:15 18:00:41'
        expected_result = []
        actual_result = sort_image_files.compute_hierarchical_path_components(
            datetime_string)

        self.assertEqual(actual_result, expected_result)
Example #4
0
    def test_datetime_string_malformed_year_missing(self):
        """
        In this test case, a malformed datetime string has been provided, where the year portion of the date is
        invalid (it is empty).

        We expect this to be caught, and for an empty list to be returned.

        :return:
        """

        datetime_string = ':01:15 18:00:41'
        expected_result = []
        actual_result = sort_image_files.compute_hierarchical_path_components(
            datetime_string)

        self.assertEqual(actual_result, expected_result)
Example #5
0
    def test_datetime_string_missing_time(self):
        """
        In this test case, the time portion has been excluded, and only the date components are present. This should
        not present a problem, as it's only the date components that we're concerned with.

        We expect that this should be successfully parsed, and the corresponding path components computed.

        :return:
        """

        datetime_string = '2020:01:15'
        expected_result = ['2020', '01 - January', '15']
        actual_result = sort_image_files.compute_hierarchical_path_components(
            datetime_string)

        self.assertEqual(actual_result, expected_result)
Example #6
0
    def test_datetime_string_malformed_day_too_large(self):
        """
        In this test case, a malformed datetime string has been provided, where the day portion of the date is
        invalid (it is outside of the upper bounds).

        We expect this to be caught, and for an empty list to be returned.

        :return:
        """

        datetime_string = '2020:01:32 18:00:41'
        expected_result = []
        actual_result = sort_image_files.compute_hierarchical_path_components(
            datetime_string)

        self.assertEqual(actual_result, expected_result)
Example #7
0
    def test_datetime_string_missing_date(self):
        """
        In this test case, the date portion has been excluded, and only the time components are present. This is in
        a similar format to the date, as it is still three components which are separated by colons. But clearly this
        is not a proper date.

        We expect this to be caught, and for an empty list to be returned.

        :return:
        """

        datetime_string = '18:00:41'
        expected_result = []
        actual_result = sort_image_files.compute_hierarchical_path_components(
            datetime_string)

        self.assertEqual(actual_result, expected_result)