Skip to content

Commit

Permalink
make date an int (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-probert authored Sep 11, 2024
1 parent ac241c8 commit 9462b14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions image_handler_client/schemas/image_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ class ImageStatus(Enum):
@dataclass(frozen=True)
class ImageInfo:
filename: str
date: str
date: int
theme: str
real: bool
status: Optional[ImageStatus] = ImageStatus.UNVERIFIED


class ImageInfoSchema(Schema):
filename = fields.Str(required=True)
date = fields.Str(required=True)
date = fields.Int(required=True)
theme = fields.Str(required=True)
real = fields.Bool(required=True)
status = fields.Field(required=False, load_default=ImageStatus.UNVERIFIED.value)
Expand Down
20 changes: 10 additions & 10 deletions tests/unit/test_image_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ def test_image_info_creation():
# Test creating an ImageInfo instance
image_info = ImageInfo(
filename="test_image.jpg",
date="2024-07-29",
date=1,
theme="wildlife",
real=True,
status=ImageStatus.VERIFIED
)
assert image_info.filename == "test_image.jpg"
assert image_info.date == "2024-07-29"
assert image_info.date == 1
assert image_info.theme == "wildlife"
assert image_info.real is True
assert image_info.status == ImageStatus.VERIFIED
Expand All @@ -22,7 +22,7 @@ def test_image_info_default_status():
# Test creating an ImageInfo instance with default status
image_info = ImageInfo(
filename="test_image.jpg",
date="2024-07-29",
date=1,
theme="wildlife",
real=True
)
Expand All @@ -33,14 +33,14 @@ def test_image_info_schema_load():
# Test loading data into ImageInfoSchema
data = {
"filename": "test_image.jpg",
"date": "2024-07-29",
"date": 1,
"theme": "wildlife",
"real": True,
"status": "verified"
}
result = IMAGE_INFO_SCHEMA.load(data)
assert result.filename == "test_image.jpg"
assert result.date == "2024-07-29"
assert result.date == 1
assert result.theme == "wildlife"
assert result.real is True
assert result.status == ImageStatus.VERIFIED
Expand All @@ -50,13 +50,13 @@ def test_image_info_schema_load_default_status():
# Test loading data into ImageInfoSchema without status
data = {
"filename": "test_image.jpg",
"date": "2024-07-29",
"date": 1,
"theme": "wildlife",
"real": True
}
result = IMAGE_INFO_SCHEMA.load(data)
assert result.filename == "test_image.jpg"
assert result.date == "2024-07-29"
assert result.date == 1
assert result.theme == "wildlife"
assert result.real is True
assert result.status == ImageStatus.UNVERIFIED
Expand All @@ -66,15 +66,15 @@ def test_image_info_schema_dump():
# Test dumping ImageInfo instance to dictionary
image_info = ImageInfo(
filename="test_image.jpg",
date="2024-07-29",
date=1,
theme="wildlife",
real=True,
status=ImageStatus.VERIFIED
)
result = IMAGE_INFO_SCHEMA.dump(image_info)
expected = {
"filename": "test_image.jpg",
"date": "2024-07-29",
"date": 1,
"theme": "wildlife",
"real": True,
"status": "verified"
Expand All @@ -86,7 +86,7 @@ def test_image_info_schema_load_invalid_status():
# Test loading data with invalid status
data = {
"filename": "test_image.jpg",
"date": "2024-07-29",
"date": 1,
"theme": "wildlife",
"real": True,
"status": "invalid_status"
Expand Down

0 comments on commit 9462b14

Please sign in to comment.