Skip to content

Commit

Permalink
🔨 refactor: rename BoolMother to BooleanMother for consistency and cl…
Browse files Browse the repository at this point in the history
…arity
  • Loading branch information
adriamontoto committed Jan 5, 2025
1 parent b125b36 commit 6fa161c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Here is how you can utilize the **Object Mother** library to generate various ty
from object_mother_pattern.mothers import (
IntegerMother,
FloatMother,
BoolMother,
BooleanMother,
StringMother,
UuidMother,
StringDateMother,
Expand All @@ -78,7 +78,7 @@ print(number)
# >>> 0.83396

# Generate a random boolean
boolean = BoolMother.create()
boolean = BooleanMother.create()
print(boolean)
# >>> True

Expand Down
4 changes: 2 additions & 2 deletions object_mother_pattern/mothers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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 .primitives import BooleanMother, BytesMother, FloatMother, IntegerMother, StringMother
from .text_mother import TextMother

__all__ = (
'BoolMother',
'BooleanMother',
'BytesMother',
'DateMother',
'DatetimeMother',
Expand Down
4 changes: 2 additions & 2 deletions object_mother_pattern/mothers/primitives/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from .bool_mother import BoolMother
from .boolean_mother import BooleanMother
from .bytes_mother import BytesMother
from .float_mother import FloatMother
from .integer_mother import IntegerMother
from .string_mother import StringMother

__all__ = (
'BoolMother',
'BooleanMother',
'BytesMother',
'FloatMother',
'IntegerMother',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
BoolMother module.
BooleanMother module.
"""

from sys import version_info
Expand All @@ -12,15 +12,15 @@
from object_mother_pattern.mothers.base_mother import BaseMother


class BoolMother(BaseMother[bool]):
class BooleanMother(BaseMother[bool]):
"""
BoolMother class.
BooleanMother class.
Example:
```python
from object_mother_pattern.mothers import BoolMother
from object_mother_pattern.mothers import BooleanMother
boolean = BoolMother.create()
boolean = BooleanMother.create()
print(boolean)
# >>> True
```
Expand All @@ -45,16 +45,16 @@ def create(cls, *, value: bool | None = None) -> bool:
Example:
```python
from object_mother_pattern.mothers import BoolMother
from object_mother_pattern.mothers import BooleanMother
boolean = BoolMother.create()
boolean = BooleanMother.create()
print(boolean)
# >>> True
```
"""
if value is not None:
if type(value) is not bool:
raise TypeError('BoolMother value must be a boolean.')
raise TypeError('BooleanMother value must be a boolean.')

return value

Expand Down
24 changes: 12 additions & 12 deletions tests/mothers/primitives/test_bool_mother.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
"""
Test module for the BoolMother class.
Test module for the BooleanMother class.
"""

from pytest import raises as assert_raises

from object_mother_pattern.mothers import BoolMother
from object_mother_pattern.mothers import BooleanMother


def test_bool_mother_happy_path() -> None:
"""
Test BoolMother happy path.
Test BooleanMother happy path.
"""
value = BoolMother.create()
value = BooleanMother.create()

assert type(value) is bool


def test_bool_mother_value() -> None:
"""
Test BoolMother create method with value.
Test BooleanMother create method with value.
"""
value = BoolMother.create()
value = BooleanMother.create()

assert BoolMother.create(value=value) == value
assert BooleanMother.create(value=value) == value


def test_bool_mother_invalid_type() -> None:
"""
Test BoolMother create method with invalid type.
Test BooleanMother create method with invalid type.
"""
assert type(BoolMother.invalid_type()) is not bool
assert type(BooleanMother.invalid_type()) is not bool


def test_bool_mother_invalid_value_type() -> None:
"""
Test BoolMother create method with invalid value type.
Test BooleanMother create method with invalid value type.
"""
with assert_raises(
expected_exception=TypeError,
match='BoolMother value must be a boolean.',
match='BooleanMother value must be a boolean.',
):
BoolMother.create(value=BoolMother.invalid_type())
BooleanMother.create(value=BooleanMother.invalid_type())

0 comments on commit 6fa161c

Please sign in to comment.