forked from sicpa-dlab/didcomm-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit tests: test generic message instead of only forward message
Signed-off-by: Sacha Kozma <[email protected]>
- Loading branch information
Showing
3 changed files
with
26 additions
and
21 deletions.
There are no files selected for viewing
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