diff --git a/README.md b/README.md index 865b752..c33ffa1 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ from object_mother_pattern.mothers import ( FloatMother, BoolMother, StringMother, - UUIDMother, + UuidMother, StringDateMother, ) @@ -93,7 +93,7 @@ print(string) # >>> 'TfkrYRxUFT' # Generate a random UUID -uuid = UUIDMother.create() +uuid = UuidMother.create() print(uuid) # >>> '3e9e0f3a-64a3-474f-9127-368e723f389f' diff --git a/object_mother_pattern/mothers/__init__.py b/object_mother_pattern/mothers/__init__.py index f20825d..c96403a 100644 --- a/object_mother_pattern/mothers/__init__.py +++ b/object_mother_pattern/mothers/__init__.py @@ -1,11 +1,5 @@ -from .additional_types import ( - DateMother, - DatetimeMother, - StringDateMother, - StringDatetimeMother, - StringUUIDMother, - UUIDMother, -) +from .dates import DateMother, DatetimeMother, StringDateMother, StringDatetimeMother +from .identifiers import StringUuidMother, UuidMother from .name_mother import NameMother from .primitives import BoolMother, BytesMother, FloatMother, IntegerMother, StringMother from .text_mother import TextMother @@ -21,7 +15,7 @@ 'StringDateMother', 'StringDatetimeMother', 'StringMother', - 'StringUUIDMother', + 'StringUuidMother', 'TextMother', - 'UUIDMother', + 'UuidMother', ) diff --git a/object_mother_pattern/mothers/additional_types/__init__.py b/object_mother_pattern/mothers/additional_types/__init__.py deleted file mode 100644 index 4305b09..0000000 --- a/object_mother_pattern/mothers/additional_types/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -from .date_mother import DateMother -from .datetime_mother import DatetimeMother -from .string_date_mother import StringDateMother -from .string_datetime_mother import StringDatetimeMother -from .string_uuid_mother import StringUUIDMother -from .uuid_mother import UUIDMother - -__all__ = ( - 'DateMother', - 'DatetimeMother', - 'StringDateMother', - 'StringDatetimeMother', - 'StringUUIDMother', - 'UUIDMother', -) diff --git a/object_mother_pattern/mothers/dates/__init__.py b/object_mother_pattern/mothers/dates/__init__.py new file mode 100644 index 0000000..46c7b29 --- /dev/null +++ b/object_mother_pattern/mothers/dates/__init__.py @@ -0,0 +1,9 @@ +from .date import DateMother, StringDateMother +from .datetime import DatetimeMother, StringDatetimeMother + +__all__ = ( + 'DateMother', + 'DatetimeMother', + 'StringDateMother', + 'StringDatetimeMother', +) diff --git a/object_mother_pattern/mothers/dates/date/__init__.py b/object_mother_pattern/mothers/dates/date/__init__.py new file mode 100644 index 0000000..88f8309 --- /dev/null +++ b/object_mother_pattern/mothers/dates/date/__init__.py @@ -0,0 +1,7 @@ +from .date_mother import DateMother +from .string_date_mother import StringDateMother + +__all__ = ( + 'DateMother', + 'StringDateMother', +) diff --git a/object_mother_pattern/mothers/additional_types/date_mother.py b/object_mother_pattern/mothers/dates/date/date_mother.py similarity index 100% rename from object_mother_pattern/mothers/additional_types/date_mother.py rename to object_mother_pattern/mothers/dates/date/date_mother.py diff --git a/object_mother_pattern/mothers/additional_types/string_date_mother.py b/object_mother_pattern/mothers/dates/date/string_date_mother.py similarity index 100% rename from object_mother_pattern/mothers/additional_types/string_date_mother.py rename to object_mother_pattern/mothers/dates/date/string_date_mother.py diff --git a/object_mother_pattern/mothers/dates/datetime/__init__.py b/object_mother_pattern/mothers/dates/datetime/__init__.py new file mode 100644 index 0000000..881d7f0 --- /dev/null +++ b/object_mother_pattern/mothers/dates/datetime/__init__.py @@ -0,0 +1,7 @@ +from .datetime_mother import DatetimeMother +from .string_datetime_mother import StringDatetimeMother + +__all__ = ( + 'DatetimeMother', + 'StringDatetimeMother', +) diff --git a/object_mother_pattern/mothers/additional_types/datetime_mother.py b/object_mother_pattern/mothers/dates/datetime/datetime_mother.py similarity index 100% rename from object_mother_pattern/mothers/additional_types/datetime_mother.py rename to object_mother_pattern/mothers/dates/datetime/datetime_mother.py diff --git a/object_mother_pattern/mothers/additional_types/string_datetime_mother.py b/object_mother_pattern/mothers/dates/datetime/string_datetime_mother.py similarity index 100% rename from object_mother_pattern/mothers/additional_types/string_datetime_mother.py rename to object_mother_pattern/mothers/dates/datetime/string_datetime_mother.py diff --git a/object_mother_pattern/mothers/identifiers/__init__.py b/object_mother_pattern/mothers/identifiers/__init__.py new file mode 100644 index 0000000..3e0f790 --- /dev/null +++ b/object_mother_pattern/mothers/identifiers/__init__.py @@ -0,0 +1,7 @@ +from .string_uuid_mother import StringUuidMother +from .uuid_mother import UuidMother + +__all__ = ( + 'StringUuidMother', + 'UuidMother', +) diff --git a/object_mother_pattern/mothers/additional_types/string_uuid_mother.py b/object_mother_pattern/mothers/identifiers/string_uuid_mother.py similarity index 79% rename from object_mother_pattern/mothers/additional_types/string_uuid_mother.py rename to object_mother_pattern/mothers/identifiers/string_uuid_mother.py index 89bf452..d1dcb25 100644 --- a/object_mother_pattern/mothers/additional_types/string_uuid_mother.py +++ b/object_mother_pattern/mothers/identifiers/string_uuid_mother.py @@ -1,5 +1,5 @@ """ -StringUUIDMother module. +StringUuidMother module. """ from random import choice @@ -13,15 +13,15 @@ from object_mother_pattern.mothers.base_mother import BaseMother -class StringUUIDMother(BaseMother[str]): +class StringUuidMother(BaseMother[str]): """ - StringUUIDMother class. + StringUuidMother class. Example: ```python - from object_mother_pattern.mothers import StringUUIDMother + from object_mother_pattern.mothers import StringUuidMother - uuid = StringUUIDMother.create() + uuid = StringUuidMother.create() print(uuid) # >>> 3e9e0f3a-64a3-474f-9127-368e723f389f ``` @@ -46,16 +46,16 @@ def create(cls, *, value: str | None = None) -> str: Example: ```python - from object_mother_pattern.mothers import StringUUIDMother + from object_mother_pattern.mothers import StringUuidMother - uuid = StringUUIDMother.create() + uuid = StringUuidMother.create() print(uuid) # >>> 3e9e0f3a-64a3-474f-9127-368e723f389f ``` """ if value is not None: if type(value) is not str: - raise TypeError('StringUUIDMother value must be a string.') + raise TypeError('StringUuidMother value must be a string.') return value diff --git a/object_mother_pattern/mothers/additional_types/uuid_mother.py b/object_mother_pattern/mothers/identifiers/uuid_mother.py similarity index 77% rename from object_mother_pattern/mothers/additional_types/uuid_mother.py rename to object_mother_pattern/mothers/identifiers/uuid_mother.py index 5efea4e..541238d 100644 --- a/object_mother_pattern/mothers/additional_types/uuid_mother.py +++ b/object_mother_pattern/mothers/identifiers/uuid_mother.py @@ -1,5 +1,5 @@ """ -UUIDMother module. +UuidMother module. """ from sys import version_info @@ -13,15 +13,15 @@ from object_mother_pattern.mothers.base_mother import BaseMother -class UUIDMother(BaseMother[UUID]): +class UuidMother(BaseMother[UUID]): """ - UUIDMother class. + UuidMother class. Example: ```python - from object_mother_pattern.mothers import UUIDMother + from object_mother_pattern.mothers import UuidMother - uuid = UUIDMother.create() + uuid = UuidMother.create() print(uuid) # >>> 3e9e0f3a-64a3-474f-9127-368e723f389f ``` @@ -46,16 +46,16 @@ def create(cls, *, value: UUID | None = None) -> UUID: Example: ```python - from object_mother_pattern.mothers import UUIDMother + from object_mother_pattern.mothers import UuidMother - uuid = UUIDMother.create() + uuid = UuidMother.create() print(uuid) # >>> 3e9e0f3a-64a3-474f-9127-368e723f389f ``` """ if value is not None: if type(value) is not UUID: - raise TypeError('UUIDMother value must be a UUID.') + raise TypeError('UuidMother value must be a UUID.') return value diff --git a/tests/mothers/additional_types/test_string_uuid_mother.py b/tests/mothers/additional_types/test_string_uuid_mother.py deleted file mode 100644 index 2cb6cac..0000000 --- a/tests/mothers/additional_types/test_string_uuid_mother.py +++ /dev/null @@ -1,56 +0,0 @@ -""" -Test module for the StringUUIDMother class. -""" - -from uuid import UUID - -from pytest import raises as assert_raises - -from object_mother_pattern.mothers import StringUUIDMother - - -def test_string_uuid_mother_happy_path() -> None: - """ - Test StringUUIDMother happy path. - """ - value = StringUUIDMother.create() - - assert type(value) is str - UUID(value) - - -def test_string_uuid_mother_value() -> None: - """ - Test StringUUIDMother create method with value. - """ - value = StringUUIDMother.create() - - assert StringUUIDMother.create(value=value) == value - - -def test_string_uuid_mother_invalid_type() -> None: - """ - Test StringUUIDMother create method with invalid type. - """ - assert type(StringUUIDMother.invalid_type()) is not str - - -def test_string_uuid_mother_invalid_value() -> None: - """ - Test StringUUIDMother invalid_value method. - """ - value = StringUUIDMother.invalid_value() - - assert type(value) is str - assert not value.isprintable() - - -def test_string_uuid_mother_invalid_value_type() -> None: - """ - Test StringUUIDMother create method with invalid value type. - """ - with assert_raises( - expected_exception=TypeError, - match='StringUUIDMother value must be a string.', - ): - StringUUIDMother.create(value=StringUUIDMother.invalid_type()) diff --git a/tests/mothers/additional_types/test_uuid_mother.py b/tests/mothers/additional_types/test_uuid_mother.py deleted file mode 100644 index 9ec8b4c..0000000 --- a/tests/mothers/additional_types/test_uuid_mother.py +++ /dev/null @@ -1,45 +0,0 @@ -""" -Test module for the UUIDMother class. -""" - -from uuid import UUID - -from pytest import raises as assert_raises - -from object_mother_pattern.mothers import UUIDMother - - -def test_uuid_mother_happy_path() -> None: - """ - Test UUIDMother happy path. - """ - value = UUIDMother.create() - - assert type(value) is UUID - - -def test_uuid_mother_value() -> None: - """ - Test UUIDMother create method with value. - """ - value = UUIDMother.create() - - assert UUIDMother.create(value=value) == value - - -def test_uuid_mother_invalid_type() -> None: - """ - Test UUIDMother create method with invalid type. - """ - assert type(UUIDMother.invalid_type()) is not UUID - - -def test_uuid_mother_invalid_value_type() -> None: - """ - Test UUIDMother create method with invalid value type. - """ - with assert_raises( - expected_exception=TypeError, - match='UUIDMother value must be a UUID.', - ): - UUIDMother.create(value=UUIDMother.invalid_type()) diff --git a/tests/mothers/additional_types/__init__.py b/tests/mothers/dates/__init__.py similarity index 100% rename from tests/mothers/additional_types/__init__.py rename to tests/mothers/dates/__init__.py diff --git a/tests/mothers/dates/date/__init__.py b/tests/mothers/dates/date/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/mothers/additional_types/test_date_mother.py b/tests/mothers/dates/date/test_date_mother.py similarity index 100% rename from tests/mothers/additional_types/test_date_mother.py rename to tests/mothers/dates/date/test_date_mother.py diff --git a/tests/mothers/additional_types/test_string_date_mother.py b/tests/mothers/dates/date/test_string_date_mother.py similarity index 100% rename from tests/mothers/additional_types/test_string_date_mother.py rename to tests/mothers/dates/date/test_string_date_mother.py diff --git a/tests/mothers/dates/datetime/__init__.py b/tests/mothers/dates/datetime/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/mothers/additional_types/test_datetime_mother.py b/tests/mothers/dates/datetime/test_datetime_mother.py similarity index 100% rename from tests/mothers/additional_types/test_datetime_mother.py rename to tests/mothers/dates/datetime/test_datetime_mother.py diff --git a/tests/mothers/additional_types/test_string_datetime_mother.py b/tests/mothers/dates/datetime/test_string_datetime_mother.py similarity index 100% rename from tests/mothers/additional_types/test_string_datetime_mother.py rename to tests/mothers/dates/datetime/test_string_datetime_mother.py diff --git a/tests/mothers/identifiers/__init__.py b/tests/mothers/identifiers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/mothers/identifiers/test_string_uuid_mother.py b/tests/mothers/identifiers/test_string_uuid_mother.py new file mode 100644 index 0000000..213e049 --- /dev/null +++ b/tests/mothers/identifiers/test_string_uuid_mother.py @@ -0,0 +1,56 @@ +""" +Test module for the StringUuidMother class. +""" + +from uuid import UUID + +from pytest import raises as assert_raises + +from object_mother_pattern.mothers import StringUuidMother + + +def test_string_uuid_mother_happy_path() -> None: + """ + Test StringUuidMother happy path. + """ + value = StringUuidMother.create() + + assert type(value) is str + UUID(value) + + +def test_string_uuid_mother_value() -> None: + """ + Test StringUuidMother create method with value. + """ + value = StringUuidMother.create() + + assert StringUuidMother.create(value=value) == value + + +def test_string_uuid_mother_invalid_type() -> None: + """ + Test StringUuidMother create method with invalid type. + """ + assert type(StringUuidMother.invalid_type()) is not str + + +def test_string_uuid_mother_invalid_value() -> None: + """ + Test StringUuidMother invalid_value method. + """ + value = StringUuidMother.invalid_value() + + assert type(value) is str + assert not value.isprintable() + + +def test_string_uuid_mother_invalid_value_type() -> None: + """ + Test StringUuidMother create method with invalid value type. + """ + with assert_raises( + expected_exception=TypeError, + match='StringUuidMother value must be a string.', + ): + StringUuidMother.create(value=StringUuidMother.invalid_type()) diff --git a/tests/mothers/identifiers/test_uuid_mother.py b/tests/mothers/identifiers/test_uuid_mother.py new file mode 100644 index 0000000..2d26571 --- /dev/null +++ b/tests/mothers/identifiers/test_uuid_mother.py @@ -0,0 +1,45 @@ +""" +Test module for the UuidMother class. +""" + +from uuid import UUID + +from pytest import raises as assert_raises + +from object_mother_pattern.mothers import UuidMother + + +def test_uuid_mother_happy_path() -> None: + """ + Test UuidMother happy path. + """ + value = UuidMother.create() + + assert type(value) is UUID + + +def test_uuid_mother_value() -> None: + """ + Test UuidMother create method with value. + """ + value = UuidMother.create() + + assert UuidMother.create(value=value) == value + + +def test_uuid_mother_invalid_type() -> None: + """ + Test UuidMother create method with invalid type. + """ + assert type(UuidMother.invalid_type()) is not UUID + + +def test_uuid_mother_invalid_value_type() -> None: + """ + Test UuidMother create method with invalid value type. + """ + with assert_raises( + expected_exception=TypeError, + match='UuidMother value must be a UUID.', + ): + UuidMother.create(value=UuidMother.invalid_type())