Skip to content

Commit

Permalink
impose schema on target flow
Browse files Browse the repository at this point in the history
see #1
  • Loading branch information
fjuniorr committed Nov 28, 2023
1 parent f3b4e68 commit 33dcaa0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion flowmapper/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def format_match_result(s: Flow, t: Flow, comment: str, is_match: bool):
result = {
'source': source_result,
'target': {
t.fields['uuid']: t.uuid,
'uuid': t.uuid,
'name': t.name,
'context': t.context.full,
'unit': t.unit
},
'conversionFactor': 1 if s.unit == t.unit else '?',
'comment': comment
Expand Down
5 changes: 4 additions & 1 deletion tests/test_flowmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def test_flowmap():
"name": "1,4-Butanediol",
"categories": ["Air", "(unspecified)"],
},
"target": {"@id": "09db39be-d9a6-4fc3-8d25-1f80b23e9131"},
"target": {"uuid": "09db39be-d9a6-4fc3-8d25-1f80b23e9131",
'name': '1,4-Butanediol',
'context': 'air/unspecified',
'unit': 'kg'},
"conversionFactor": 1,
"comment": "Identical names",
},
Expand Down
5 changes: 4 additions & 1 deletion tests/test_format_match_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def test_format_match_result_missing_id():

actual = format_match_result(s, t, is_match=True, comment="foo")
expected = {'source': {'name': 'Carbon dioxide, in air', 'context': 'Raw materials'},
'target': {'id': 'cc6a1abb-b123-4ca6-8f16-38209df609be'},
'target': {'uuid': 'cc6a1abb-b123-4ca6-8f16-38209df609be',
'name': 'Carbon dioxide, in air',
'context': 'natural resource/in air',
'unit': 'kg'},
'conversionFactor': 1,
'comment': 'foo'}

Expand Down

0 comments on commit 33dcaa0

Please sign in to comment.