Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EiffelBaseEvent.rebuild mutate the input json object #44

Open
jgse opened this issue Jan 27, 2022 · 1 comment
Open

EiffelBaseEvent.rebuild mutate the input json object #44

jgse opened this issue Jan 27, 2022 · 1 comment

Comments

@jgse
Copy link

jgse commented Jan 27, 2022

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'}}}
@jgse
Copy link
Author

jgse commented Jan 30, 2022

the bug must be from below in rebuild() method in class EiffelBaseMeta(object)

        self.type = meta.pop("type")
        self.version = meta.pop("version")
        self.time = meta.pop("time")
        self.event_id = meta.pop("id")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant