-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_chain.py
58 lines (40 loc) · 1.35 KB
/
test_chain.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Entrypoint Unit Tests.
The chain test file ensures that we are being able to create a new chain that can
execute the basic desired methods.
"""
import chain
from pytest import main
from sys import argv
from faker import Faker
from unittest.mock import patch, MagicMock
from chain.tests.helpers import DependencyMocker
file_path = "chain"
dependencies = DependencyMocker(file_path)
@patch.multiple(file_path, **dependencies.to_dict())
def test_call(fake: Faker, Decorator: MagicMock = None, **kwargs) -> None:
"""Test the Entrypoint Call.
Ensures that when we call the entrypoint it will automatically redirect
to the creation of a decorator, passing args and kwargs.
"""
# Given
args = fake.word()
kwargs = fake.pydict()
# When
created_chain = chain(*args, **kwargs)
# Then
Decorator.assert_called_once_with(*args, **kwargs)
@patch.multiple(file_path, **dependencies.to_dict())
def test_state(fake: Faker, State: MagicMock = None, **kwargs) -> None:
"""Test the State Creation.
Ensures that when we call the state method it is creating and returning a
new chain state.
"""
# Given
kwargs = fake.pydict()
# When
state = chain.state(**kwargs)
# Then
State.assert_called_once_with(**kwargs)
if __name__ == "__main__":
args = [__file__] + [arg for arg in argv[1:]]
main(args)