Skip to content

Commit

Permalink
+1 test
Browse files Browse the repository at this point in the history
  • Loading branch information
pomponchik committed Aug 6, 2024
1 parent 73a52e2 commit 586b325
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cantok/tokens/counter_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, counter: int, *tokens: AbstractToken, cancelled: bool = False
self.initial_counter = counter
self.direct = direct
self.rollback_if_nondirect_polling = self.direct

def function() -> bool:
with self.lock:
if not self.counter:
Expand Down
26 changes: 25 additions & 1 deletion tests/units/tokens/abstract/test_abstract_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_str(token_fabric):
'second_token_fabric',
ALL_TOKENS_FABRICS,
)
def test_add_tokens(first_token_fabric, second_token_fabric):
def test_add_not_temp_tokens(first_token_fabric, second_token_fabric):
first_token = first_token_fabric()
second_token = second_token_fabric()

Expand All @@ -154,6 +154,30 @@ def test_add_tokens(first_token_fabric, second_token_fabric):
assert tokens_sum.tokens[1] is second_token


@pytest.mark.parametrize(
['first_token_class', 'first_arguments'],
[
(TimeoutToken, [15]),
(ConditionToken, [lambda: False]),
#(CounterToken, [15]),
],
)
@pytest.mark.parametrize(
['second_token_class', 'second_arguments'],
[
(TimeoutToken, [15]),
(ConditionToken, [lambda: False]),
#(CounterToken, [15]),
],
)
def test_add_temp_tokens(first_token_class, second_token_class, first_arguments, second_arguments):
tokens_sum = first_token_class(*first_arguments) + second_token_class(*second_arguments)

assert isinstance(tokens_sum, first_token_class)
assert len(tokens_sum.tokens) == 1
assert isinstance(tokens_sum.tokens[0], second_token_class)


@pytest.mark.parametrize(
'first_token_fabric',
ALL_TOKENS_FABRICS_WITH_NOT_CANCELLING_SUPERPOWER,
Expand Down

0 comments on commit 586b325

Please sign in to comment.