chore: update the test files

This commit is contained in:
2023-07-24 17:59:54 +08:00
committed by Bryant He
parent dd23c91192
commit 0777788609
2 changed files with 13 additions and 4 deletions

View File

@@ -2,10 +2,19 @@
Service unit testing best practice.
"""
import pytest
from nameko.testing.services import worker_factory
def test_example_service():
@pytest.mark.parametrize(
'value, expected',
[
('John Doe', 'Hello, John Doe!'),
('', 'Hello, !'),
('Bryant', 'Hello, Bryant!'),
],
)
def test_example_service(value, expected):
"""
Test example service.
"""
@@ -16,5 +25,5 @@ def test_example_service():
service.remote.hello.side_effect = lambda name: "Hello, {}!".format(name)
# test remote_hello business logic
assert service.remote_hello("Bryant") == "Hello, Bryant!"
service.remote.hello.assert_called_once_with("Bryant")
assert service.remote_hello(value) == expected
service.remote.hello.assert_called_once_with(value)