Skip to content

Commit

Permalink
0.1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
xncbf committed Feb 4, 2022
1 parent 2dbae98 commit b96b684
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rcs-pydantic"
version = "0.1.18"
version = "0.1.19"
description = ""
authors = ["xncbf <xncbf12@gmail.com>"]
keywords = ["pydantic", "rcs", "fastapi"]
Expand Down
2 changes: 1 addition & 1 deletion rcs_pydantic/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class BillEnum(IntEnum):
class EventTypeEnum(Enum):
MESSAGE: str = "message"
RESPONSE: str = "response"
NEW_USER: str = "newuser"
NEW_USER: str = "newUser"


class RCSMessageEnum(Enum):
Expand Down
4 changes: 4 additions & 0 deletions rcs_pydantic/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def _missing_(cls, value):
return item
return super()._missing_(value)

@classmethod
def has_value(cls, value):
return value in [x[0] for x in cls._value2member_map_]


class LegacyErrorCodeEnum(str, TupleEnum):
pass
Expand Down
2 changes: 1 addition & 1 deletion rcs_pydantic/scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def check_message_body(cls, v, values, **kwargs):

userContact: str = Field(max_length=40)
chatbotId: str = Field(max_length=40)
timestamp: str = Field(regex=r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}\+\d{2}$")
timeStamp: str = Field(regex=r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}\+\d{2}$")


class SendInfo(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion tests/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class Meta:
chatbotId: str = factory.LazyAttribute(lambda n: fake.sentence(nb_words=10)[:40])

@factory.lazy_attribute
def timestamp(self) -> str:
def timeStamp(self) -> str:
t = datetime.now()
s: str = t.strftime("%Y-%m-%dT%H:%M:%S.%f")
s = s[:-3]
Expand Down
5 changes: 5 additions & 0 deletions tests/test_rcs_pydantic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from faker import Faker

from rcs_pydantic.errors import ErrorCodeEnum
from rcs_pydantic.main import RcsMessage

from . import factory
Expand All @@ -15,3 +16,7 @@ def test_rcs_message():
buttons=[factory.ButtonInfoFactory()],
)
rcs_message.send()


def test_tuple_enum_has_value():
assert ErrorCodeEnum.has_value(ErrorCodeEnum.MISSING_AUTHORIZATION_HEADER.value[0])

0 comments on commit b96b684

Please sign in to comment.