Beispiel #1
0
    def test__get_placeholders_on_text_with_one_placeholder(self):
        """
        Should return a Match object containing all matched placeholders.
        """
        expected_text = "test_placeholder"
        text = f"{Placeholder.PLACEHOLDER_START}{expected_text}{Placeholder.PLACEHOLDER_END}"

        actual_matches = Placeholder._get_placeholders(text_to_check=text)

        self.assertEqual(expected_text, actual_matches[0])
Beispiel #2
0
    def test__get_placeholder_placeholder_with_whitespace_in_string(self):
        """
        Should return empty Matches
        :return:
        """
        from businesslogic.placeholders import Placeholder

        expected_string = "string one!@nested @! placeholder"
        expected_matches = []
        actual_matches = Placeholder._get_placeholders(expected_string)

        self.assertEqual(expected_matches, actual_matches)
Beispiel #3
0
    def test__get_placeholder_nested_placeholder(self):
        """
        Should only return the nested placeholder
        :return:
        """
        from businesslogic.placeholders import Placeholder

        expected_string = "string !@one!@nested@!@! placeholder"
        expected_matches = ['nested']
        actual_matches = Placeholder._get_placeholders(expected_string)

        self.assertEqual(expected_matches, actual_matches)
Beispiel #4
0
    def test__get_placeholders_three_placeholders(self):
        """
        Should return Matches with the three provided placeholders
        :return:
        """
        from businesslogic.placeholders import Placeholder

        expected_string = "string !@one@!, !@two@!, !@three@! placeholder"
        expected_matches = ['one', 'two', 'three']
        actual_matches = Placeholder._get_placeholders(expected_string)

        self.assertEqual(expected_matches, actual_matches)
Beispiel #5
0
    def test__get_placeholders_no_placeholder(self):
        """
        Should return empty Matches
        :return:
        """
        from businesslogic.placeholders import Placeholder

        expected_string = "string without placeholders"
        expected_matches = []
        actual_matches = Placeholder._get_placeholders(expected_string)

        self.assertEqual(expected_matches, actual_matches)
Beispiel #6
0
    def test__get_placeholders_on_text_with_three_placeholders(self):
        """
        Should return a Match object containing three matched placeholders.
        """
        expected_matches = ["Hello", "there", "fool"]
        text = f"{Placeholder.PLACEHOLDER_START}{expected_matches[0]}{Placeholder.PLACEHOLDER_END} " \
               f"{Placeholder.PLACEHOLDER_START}{expected_matches[1]}{Placeholder.PLACEHOLDER_END} " \
               f"{Placeholder.PLACEHOLDER_START}{expected_matches[2]}{Placeholder.PLACEHOLDER_END}"

        actual_matches = Placeholder._get_placeholders(text_to_check=text)

        self.assertEqual(expected_matches, actual_matches)