eiffel-community / eiffel-community/eiffel-pythonlib

`EiffelBaseEvent.rebuild` mutate the input json object

Open
#44 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
8
Forks
12
PR merge metrics
No merged PRs in 30d

Description

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

```python
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'}}}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.