-
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.
- Loading branch information
Showing
1 changed file
with
26 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
"""Plugin tests.""" | ||
import pytest | ||
|
||
from cmem_plugin_ulid.transform import ULIDTransformPlugin | ||
from cmem_plugin_ulid.transform import ULIDTransformPlugin, URN_PREFIX | ||
|
||
|
||
def test_transform_execution_with_optional_input(): | ||
"""Test Lifetime with optional input""" | ||
result = ULIDTransformPlugin().transform(inputs=[]) | ||
def test_execution(): | ||
"""Test execution""" | ||
# default case | ||
assert len(ULIDTransformPlugin().transform(inputs=[])) == 1 | ||
|
||
# multiple values | ||
assert len(ULIDTransformPlugin(number_of_values=2).transform(inputs=[])) == 2 | ||
assert len(ULIDTransformPlugin(number_of_values=3).transform(inputs=[])) == 3 | ||
|
||
# as urn | ||
result = ULIDTransformPlugin(generate_urn=True).transform(inputs=[]) | ||
assert len(result) == 1 | ||
for _ in result: | ||
assert _.startswith(URN_PREFIX) | ||
|
||
result = ULIDTransformPlugin(number_of_values=2).transform(inputs=[]) | ||
assert len(result) == 2 | ||
|
||
def test_fails(): | ||
"""Test fails.""" | ||
# no inputs allowed | ||
with pytest.raises(ValueError): | ||
ULIDTransformPlugin().transform( | ||
inputs=[["2000-05-22", "2021-12-12", "1904-02-29"]] | ||
) | ||
|
||
def test_transform_execution_with_inputs(): | ||
"""Test Lifetime with sequence of inputs.""" | ||
result = ULIDTransformPlugin().transform( | ||
inputs=[["2000-05-22", "2021-12-12", "1904-02-29"]] | ||
) | ||
assert len(result) == 1 | ||
with pytest.raises(ValueError): | ||
ULIDTransformPlugin(number_of_values=-0).transform(inputs=[]) | ||
with pytest.raises(ValueError): | ||
ULIDTransformPlugin(number_of_values=-1).transform(inputs=[]) |