Skip to content

EiffelBaseEvent.rebuild mutate the input json object #44

@jgse

Description

@jgse

Description

Can be reproduced with below code, the original_event is mutated after passing in to rebuild method.

import eiffellib.events
from pprint import pprint

original_event = {
    'data': {'customData': [{'key': 'name', 'value': 'TCF4'},
                        {'key': 'iteration', 'value': 4}],
        'outcome': {'conclusion': 'SUCCESSFUL', 'verdict': 'PASSED'}},
'links': [{'target': 'ea44d3ed-0c22-4833-8bc4-139a17fe93b0',
        'type': 'TEST_CASE_EXECUTION'}],
'meta': {'id': '39420db3-69fa-4786-a521-420357e5665d',
        'source': {'domainId': 'example.domain'},
        'time': 1533635195805,
        'type': 'EiffelTestCaseFinishedEvent',
        'version': '1.0.0'}
}

meta_type = original_event.get("meta", {}).get("type")
new_event = getattr(eiffellib.events, meta_type)(original_event.get("meta", {}).get("version"))
new_event.rebuild(original_event)  # FIXME: rebuild method mutate the input object!

pprint(original_event)

The print output is as below. The propertities in meta are removed except the source

{'data': {'customData': [{'key': 'name', 'value': 'TCF4'},
                         {'key': 'iteration', 'value': 4}],
          'outcome': {'conclusion': 'SUCCESSFUL', 'verdict': 'PASSED'}},
 'links': [{'target': 'ea44d3ed-0c22-4833-8bc4-139a17fe93b0',
            'type': 'TEST_CASE_EXECUTION'}],
 'meta': {'source': {'domainId': 'example.domain'}}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions