Commit 494e7182 authored by Marco Cavalli's avatar Marco Cavalli
Browse files

fix: use generic name (without context) for the base testcase when there are...

fix: use generic name (without context) for the base testcase when there are permutations based on the context
parent 8c2f05f7
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -972,8 +972,13 @@ class GenerateRobotData:
        tags = self.robot.get_iop_test_tags(test_name)
        comments = self.robot.get_iop_comments(test_name)

        name = test_name
        if len(self.robot.test_case_names) > 1:
            name = name.replace(' With Default Context', '')
            name = name.replace(' With User Context', '')
        
        test_case = {
            'name': test_name,
            'name': name,
            'permutation_iop_id': self.base_TP_id,
            'tags': tags,
            'test_steps': comments,
+26 −4
Original line number Diff line number Diff line
@@ -11,7 +11,13 @@ from analysis.generaterobotdata import GenerateRobotData


class IopPreconditionsTest(unittest.TestCase):
    def generate(self, variables: str, setup: str, test_body: str = '    No Operation'):
    def generate(
        self,
        variables: str,
        setup: str,
        test_body: str = '    No Operation',
        test_name: str = 'IOP_999_01 Generated Preconditions',
    ):
        robot = f'''*** Settings ***
Documentation       Objective
Test Setup          Prepare Preconditions
@@ -22,7 +28,7 @@ Test Setup Prepare Preconditions


*** Test Cases ***
IOP_999_01 Generated Preconditions
{test_name}
    [Documentation]    Pre-conditions: documentation must be ignored.
    [Tags]
    ...    since_v1.6.1
@@ -70,6 +76,18 @@ Prepare Preconditions
            ['since_v1.6.1', 'iop', '4_3_3']
        )

    def test_preserves_context_in_single_test_case_name(self):
        self.generate(
            variables='${b1_url}    ${EMPTY}',
            setup='    No Operation',
            test_name='IOP_999_01 Scenario With Default Context',
        )

        self.assertEqual(
            self.generated_info['test_cases'][0]['name'],
            'IOP_999_01 Scenario With Default Context'
        )

    def test_generates_mixed_context_and_data_objects(self):
        result = self.generate(
            variables='''${first_payload}     fixtures/first-entity.jsonld
@@ -181,12 +199,12 @@ ${b1_url} ${EMPTY}


*** Test Cases ***
IOP_999_01_01 Default Context
IOP_999_01_01 Scenario With Default Context
    [Tags]    since_v1.6.1    iop    4_3_3    default-context
    [Setup]    Prepare Preconditions    ${core_context}
    ${core_context}

IOP_999_01_02 User Context
IOP_999_01_02 Scenario With User Context
    [Tags]    since_v1.6.1    iop    4_3_3    user-context
    [Setup]    Prepare Preconditions    context=${ngsild_test_suite_context}
    ${ngsild_test_suite_context}
@@ -210,6 +228,10 @@ Prepare Preconditions
        user_conditions = self.generated_info['test_cases'][1]['initial_conditions']

        self.assertNotIn('initial_conditions', self.generated_info)
        self.assertEqual(
            [test_case['name'] for test_case in self.generated_info['test_cases']],
            ['IOP_999_01_01 Scenario', 'IOP_999_01_02 Scenario']
        )
        self.assertEqual(
            default_conditions['pre_conditions'][0],
            {