hestia-earth-models 0.65.6__py3-none-any.whl → 0.65.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. hestia_earth/models/config/Cycle.json +2193 -0
  2. hestia_earth/models/config/ImpactAssessment.json +2041 -0
  3. hestia_earth/models/config/Site.json +471 -0
  4. hestia_earth/models/config/__init__.py +71 -0
  5. hestia_earth/models/config/run-calculations.json +42 -0
  6. hestia_earth/models/config/trigger-calculations.json +43 -0
  7. hestia_earth/models/ipcc2019/animal/hoursWorkedPerDay.py +38 -0
  8. hestia_earth/models/mocking/search-results.json +4524 -27
  9. hestia_earth/models/version.py +1 -1
  10. hestia_earth/orchestrator/__init__.py +40 -0
  11. hestia_earth/orchestrator/log.py +62 -0
  12. hestia_earth/orchestrator/models/__init__.py +118 -0
  13. hestia_earth/orchestrator/models/emissions/__init__.py +0 -0
  14. hestia_earth/orchestrator/models/emissions/deleted.py +15 -0
  15. hestia_earth/orchestrator/models/transformations.py +103 -0
  16. hestia_earth/orchestrator/strategies/__init__.py +0 -0
  17. hestia_earth/orchestrator/strategies/merge/__init__.py +42 -0
  18. hestia_earth/orchestrator/strategies/merge/merge_append.py +29 -0
  19. hestia_earth/orchestrator/strategies/merge/merge_default.py +1 -0
  20. hestia_earth/orchestrator/strategies/merge/merge_list.py +103 -0
  21. hestia_earth/orchestrator/strategies/merge/merge_node.py +59 -0
  22. hestia_earth/orchestrator/strategies/run/__init__.py +8 -0
  23. hestia_earth/orchestrator/strategies/run/add_blank_node_if_missing.py +85 -0
  24. hestia_earth/orchestrator/strategies/run/add_key_if_missing.py +9 -0
  25. hestia_earth/orchestrator/strategies/run/always.py +6 -0
  26. hestia_earth/orchestrator/utils.py +116 -0
  27. {hestia_earth_models-0.65.6.dist-info → hestia_earth_models-0.65.7.dist-info}/METADATA +27 -5
  28. {hestia_earth_models-0.65.6.dist-info → hestia_earth_models-0.65.7.dist-info}/RECORD +51 -7
  29. tests/models/ipcc2019/animal/test_hoursWorkedPerDay.py +22 -0
  30. tests/models/test_config.py +115 -0
  31. tests/orchestrator/__init__.py +0 -0
  32. tests/orchestrator/models/__init__.py +0 -0
  33. tests/orchestrator/models/emissions/__init__.py +0 -0
  34. tests/orchestrator/models/emissions/test_deleted.py +21 -0
  35. tests/orchestrator/models/test_transformations.py +29 -0
  36. tests/orchestrator/strategies/__init__.py +0 -0
  37. tests/orchestrator/strategies/merge/__init__.py +0 -0
  38. tests/orchestrator/strategies/merge/test_merge_append.py +33 -0
  39. tests/orchestrator/strategies/merge/test_merge_default.py +7 -0
  40. tests/orchestrator/strategies/merge/test_merge_list.py +327 -0
  41. tests/orchestrator/strategies/merge/test_merge_node.py +95 -0
  42. tests/orchestrator/strategies/run/__init__.py +0 -0
  43. tests/orchestrator/strategies/run/test_add_blank_node_if_missing.py +114 -0
  44. tests/orchestrator/strategies/run/test_add_key_if_missing.py +14 -0
  45. tests/orchestrator/strategies/run/test_always.py +5 -0
  46. tests/orchestrator/test_models.py +69 -0
  47. tests/orchestrator/test_orchestrator.py +27 -0
  48. tests/orchestrator/test_utils.py +109 -0
  49. {hestia_earth_models-0.65.6.dist-info → hestia_earth_models-0.65.7.dist-info}/LICENSE +0 -0
  50. {hestia_earth_models-0.65.6.dist-info → hestia_earth_models-0.65.7.dist-info}/WHEEL +0 -0
  51. {hestia_earth_models-0.65.6.dist-info → hestia_earth_models-0.65.7.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,109 @@
1
+ from hestia_earth.orchestrator.utils import update_node_version
2
+
3
+ version = '2'
4
+
5
+
6
+ def test_update_node_version():
7
+ current_data = {
8
+ 'key1': 50,
9
+ 'key2': 100
10
+ }
11
+ new_data = {
12
+ 'key2': 200,
13
+ 'key3': 300,
14
+ 'key4': {}
15
+ }
16
+ assert update_node_version(version, new_data, current_data) == {
17
+ **new_data,
18
+ 'added': ['key3', 'key4'],
19
+ 'addedVersion': [version, version],
20
+ 'updated': ['key2'],
21
+ 'updatedVersion': [version]
22
+ }
23
+
24
+
25
+ def test_update_node_version_deep():
26
+ current_data = {
27
+ 'object': {
28
+ 'first': True
29
+ },
30
+ 'values': [
31
+ {
32
+ 'term': {'@type': 'Term'},
33
+ 'value': [500],
34
+ 'properties': [
35
+ {
36
+ 'term': {'@type': 'Term', '@id': 'Prop1'},
37
+ 'value': 100
38
+ }
39
+ ]
40
+ }
41
+ ]
42
+ }
43
+ new_data = {
44
+ 'object': {
45
+ 'first': True,
46
+ 'second': False
47
+ },
48
+ 'values': [
49
+ {
50
+ 'term': {'@type': 'Term'},
51
+ 'value': [500],
52
+ 'min': [100],
53
+ 'properties': [
54
+ {
55
+ 'term': {'@type': 'Term', '@id': 'Prop1'},
56
+ 'value': 10
57
+ },
58
+ {
59
+ 'term': {'@type': 'Term', '@id': 'Prop2'},
60
+ 'value': 20
61
+ }
62
+ ]
63
+ },
64
+ {
65
+ 'term': {'@type': 'Term', '@id': 'Test2'}
66
+ }
67
+ ]
68
+ }
69
+ result = update_node_version(version, new_data, current_data)
70
+ assert result == {
71
+ 'object': {
72
+ 'first': True,
73
+ 'second': False,
74
+ 'added': ['second'],
75
+ 'addedVersion': [version]
76
+ },
77
+ 'values': [
78
+ {
79
+ 'term': {'@type': 'Term'},
80
+ 'value': [500],
81
+ 'min': [100],
82
+ 'properties': [
83
+ {
84
+ 'term': {'@type': 'Term', '@id': 'Prop1'},
85
+ 'value': 10,
86
+ 'updated': ['value'],
87
+ 'updatedVersion': [version]
88
+ },
89
+ {
90
+ 'term': {'@type': 'Term', '@id': 'Prop2'},
91
+ 'value': 20,
92
+ 'added': ['term', 'value'],
93
+ 'addedVersion': [version, version]
94
+ }
95
+ ],
96
+ 'added': ['min'],
97
+ 'addedVersion': [version],
98
+ 'updated': ['properties'],
99
+ 'updatedVersion': [version]
100
+ },
101
+ {
102
+ 'term': {'@type': 'Term', '@id': 'Test2'},
103
+ 'added': ['term'],
104
+ 'addedVersion': [version]
105
+ }
106
+ ],
107
+ 'updated': ['object', 'values'],
108
+ 'updatedVersion': [version, version]
109
+ }