Skip to content

Commit

Permalink
Fix testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Buried-In-Code committed Oct 2, 2024
1 parent 049c122 commit 126fee0
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 33 deletions.
36 changes: 35 additions & 1 deletion esak/schemas/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
"""esak.schemas package entry file."""
"""esak.schemas package entry file.
This module provides the following classes:
- BaseModel
"""

__all__ = ["BaseModel"]

from pydantic import BaseModel as PydanticModel


def to_camel_case(value: str) -> str:
"""Convert attribute name to camelCase.
Args:
value: Attribute name
Returns:
Value converted to camelCase
"""
temp = value.replace("_", " ").title().replace(" ", "")
return temp[0].lower() + temp[1:]


class BaseModel(
PydanticModel,
alias_generator=to_camel_case,
populate_by_name=True,
str_strip_whitespace=True,
validate_assignment=True,
revalidate_instances="always",
extra="ignore",
):
"""Base model for esak resources."""
31 changes: 3 additions & 28 deletions esak/schemas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,19 @@
This module provides the following classes:
- BaseModel
- BaseResource
"""

__all__ = ["BaseResource", "BaseModel"]
__all__ = ["BaseResource"]

from datetime import datetime

from pydantic import BaseModel as PydanticModel, Field, HttpUrl, field_validator
from pydantic import Field, HttpUrl, field_validator

from esak.schemas import BaseModel
from esak.schemas.urls import Urls


def to_camel_case(value: str) -> str:
"""Convert attribute name to camelCase.
Args:
value: Attribute name
Returns:
Value converted to camelCase
"""
temp = value.replace("_", " ").title().replace(" ", "")
return temp[0].lower() + temp[1:]


class BaseModel(
PydanticModel,
alias_generator=to_camel_case,
populate_by_name=True,
str_strip_whitespace=True,
validate_assignment=True,
revalidate_instances="always",
extra="ignore",
):
"""Base model for esak resources."""


class BaseResource(BaseModel):
r"""Base resource for esak resources.
Expand Down
3 changes: 2 additions & 1 deletion esak/schemas/comic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

from pydantic import ConfigDict, Field, HttpUrl, field_validator

from esak.schemas.base import BaseModel, BaseResource
from esak.schemas import BaseModel
from esak.schemas.base import BaseResource
from esak.schemas.generic import GenericCreator, GenericItem, GenericStory


Expand Down
2 changes: 1 addition & 1 deletion esak/schemas/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from pydantic import Field, HttpUrl

from esak.schemas.base import BaseModel
from esak.schemas import BaseModel


class GenericItem(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion esak/schemas/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from pydantic import HttpUrl

from esak.schemas.base import BaseModel
from esak.schemas import BaseModel


class Urls(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ envlist = py3{10,11,12}
min_version = 4.0

[testenv]
whitelist_externals = poetry
allowlist_externals = poetry
commands =
poetry install -v
poetry run pytest tests/

0 comments on commit 126fee0

Please sign in to comment.