Skip to content

Commit

Permalink
fix and extend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seebi committed Oct 19, 2023
1 parent 4b4d2ab commit f4cdbfe
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions tests/test_ulid.py
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=[])

0 comments on commit f4cdbfe

Please sign in to comment.