-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from sicpa-dlab/feat/message-id-autocreation
Improve `id` and `thid` management
- Loading branch information
Showing
10 changed files
with
56 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
import attr | ||
|
||
from didcomm.core import converters | ||
from didcomm.message import GenericMessage | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"m_id, m_id_expected", | ||
[ | ||
pytest.param("123", "123", id="str"), | ||
pytest.param(lambda: "345", "345", id="function"), | ||
pytest.param(None, None, id="default"), | ||
], | ||
) | ||
def test_forward_message__id_good(m_id, m_id_expected, mocker): | ||
if m_id is None: | ||
# XXX mocks in-place of imports doesn't work for attrs calsses | ||
# by some reason | ||
spy = mocker.spy(converters, "didcomm_id_generator_default") | ||
msg = GenericMessage(type="test_type", body="test_body") | ||
assert spy.call_count == 1 | ||
assert msg.id == spy.spy_return | ||
else: | ||
msg = GenericMessage(type="test_type", body="test_body") | ||
assert attr.evolve(msg, **dict(id=m_id)).id == m_id_expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters