Commit a1659f3c authored by Marco Cavalli's avatar Marco Cavalli
Browse files

fix: changed text generated by the script

parent 8e9c40fc
Loading
Loading
Loading
Loading
+15 −14
Original line number Diff line number Diff line
@@ -801,7 +801,7 @@ class GenerateRobotData:
            }
        ]

    def generate_iop_registrations(self, test_name: str) -> str:
    def generate_iop_registrations(self, test_name: str) -> list:
        """Generate the registration description from the test setup."""
        setup = self._get_iop_setup(test_name=test_name)
        modes = {'inclusive', 'exclusive', 'redirect', 'auxiliary'}
@@ -815,14 +815,10 @@ class GenerateRobotData:
            if mode not in modes:
                continue

            payload_variable = str(keyword.args[1])
            try:
                payload_path = self.robot.variables[payload_variable]
            except KeyError:
                raise ValueError(
                    f"Registration payload variable '{payload_variable}' is not defined"
            payload_filename = self._iop_filename(
                value=str(keyword.args[1]),
                field='Registration payload'
            )

            brokers = []
            for broker_variable in (str(keyword.args[4]), str(keyword.args[3])):
                broker_match = match(r'^\$\{(b\d+)_url\}$', broker_variable)
@@ -832,12 +828,17 @@ class GenerateRobotData:
                    )
                brokers.append(broker_match.group(1))

            registrations.append(
                f"{mode.capitalize()} from {brokers[0]} to {brokers[1]} "
                f"(Figure {basename(payload_path)})"
            registrations.append((
                int(brokers[0][1:]),
                int(brokers[1][1:]),
                (
                    f"{mode.capitalize()} {brokers[0]} to {brokers[1]} "
                    f"(Figure {payload_filename})."
                )
            ))

        return '. '.join(registrations)
        registrations.sort(key=lambda item: (item[0], item[1]))
        return list(dict.fromkeys(item[2] for item in registrations))

    def visit_test_iop(self, test_name: str, suite_setup: str = "", suite_teardown: str = ""):
        """Process a single IOP test case"""
+4 −4
Original line number Diff line number Diff line
@@ -663,14 +663,14 @@ class ParseRobotFile:
            return []

        test_content = self.test_cases[test_name]
        pattern = r'\[Tags\]\s*(.*?)(?=\n\s+\[|\n\s*$)'
        match = re.search(pattern, test_content, re.MULTILINE | re.DOTALL)
        pattern = r'^[ \t]*\[Tags\][ \t]*(?P<tags>[^\n]*(?:\n[ \t]*\.{3}[^\n]*)*)'
        match = re.search(pattern, test_content, re.MULTILINE)

        if not match:
            return []

        tags_text = match.group(1)
        return [tag.strip() for tag in tags_text.split() if tag.strip()]
        tags_text = match.group('tags')
        return [tag for tag in tags_text.split() if tag != '...']

    def get_iop_comments(self, test_name: str) -> list:
        """Extract comments from a specific IOP test case."""
+68 −2
Original line number Diff line number Diff line
@@ -24,7 +24,10 @@ Test Setup Prepare Preconditions
*** Test Cases ***
IOP_999_01 Generated Preconditions
    [Documentation]    Pre-conditions: documentation must be ignored.
    [Tags]    since_v1.6.1    iop    4_3_3
    [Tags]
    ...    since_v1.6.1
    ...    iop
    ...    4_3_3
{test_body}


@@ -49,7 +52,19 @@ Prepare Preconditions

        generator = GenerateRobotData(robot_file=str(path), execdir=str(ROOT))
        generator.parse_robot()
        return generator.get_info()['initial_conditions']
        self.generated_info = generator.get_info()
        return self.generated_info['initial_conditions']

    def test_removes_tag_continuation_markers(self):
        self.generate(
            variables='${b1_url}    ${EMPTY}',
            setup='    No Operation'
        )

        self.assertEqual(
            self.generated_info['test_cases'][0]['tags'],
            ['since_v1.6.1', 'iop', '4_3_3']
        )

    def test_generates_context_and_data_objects(self):
        result = self.generate(
@@ -151,6 +166,57 @@ ${b3_url} ${EMPTY}''',
                }
            ]
        )
        self.assertEqual(result['registrations_established'], [])

    def test_generates_sorted_registration_array(self):
        result = self.generate(
            variables='''${b1_url}     ${EMPTY}
${b2_url}     ${EMPTY}
${b3_url}     ${EMPTY}
${b5_url}     ${EMPTY}
${b10_url}    ${EMPTY}''',
            setup='''    @{redirect}=    Create List
    ...    ${EMPTY}
    ...    redirect.jsonld
    ...    redirect
    ...    ${b5_url}
    ...    ${b1_url}
    @{last}=    Create List
    ...    ${EMPTY}
    ...    exclusive.jsonld
    ...    exclusive
    ...    ${b1_url}
    ...    ${b10_url}
    @{duplicate}=    Create List
    ...    urn:ngsi-ld:Example:1
    ...    exclusive-other.jsonld
    ...    exclusive
    ...    ${b1_url}
    ...    ${b10_url}
    @{inclusive}=    Create List
    ...    ${EMPTY}
    ...    inclusive.jsonld
    ...    inclusive
    ...    ${b2_url}
    ...    ${b1_url}
    @{auxiliary}=    Create List
    ...    ${EMPTY}
    ...    auxiliary.jsonld
    ...    auxiliary
    ...    ${b3_url}
    ...    ${b2_url}'''
        )

        self.assertEqual(
            result['registrations_established'],
            [
                'Inclusive b1 to b2 (Figure inclusive.jsonld).',
                'Redirect b1 to b5 (Figure redirect.jsonld).',
                'Auxiliary b2 to b3 (Figure auxiliary.jsonld).',
                'Exclusive b10 to b1 (Figure exclusive.jsonld).',
                'Exclusive b10 to b1 (Figure exclusive-other.jsonld).'
            ]
        )

    def test_rejects_invalid_broker(self):
        with self.assertRaisesRegex(