-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from cloudblue/LITE-29272-create-upload-entity…
…-representation LITE-29272 Create upload entity representation
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from typing import Optional | ||
|
||
from connect_extension_utils.api.schemas import Events, NonNullSchema, ReferenceSchema | ||
|
||
|
||
class UploadSchema(NonNullSchema): | ||
id: str | ||
name: Optional[str] | ||
feed: ReferenceSchema | ||
report: ReferenceSchema | ||
size: Optional[int] | ||
status: str | ||
events: Events |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from connect_bi_reporter.uploads.api.schemas import UploadSchema | ||
|
||
|
||
def test_upload_get_and_list_schema_full(upload_factory): | ||
upload = upload_factory(size=600, name='My upload') | ||
serializer = UploadSchema( | ||
id=upload.id, | ||
name=upload.name, | ||
feed={'id': upload.feed_id}, | ||
report={'id': 'RR-123'}, | ||
size=upload.size, | ||
events={ | ||
'created': {'at': upload.created_at}, | ||
'updated': {'at': upload.updated_at}, | ||
}, | ||
status=upload.status, | ||
) | ||
|
||
assert serializer.dict() == { | ||
'id': upload.id, | ||
'name': upload.name, | ||
'feed': {'id': upload.feed_id}, | ||
'report': {'id': 'RR-123'}, | ||
'size': upload.size, | ||
'events': { | ||
'created': {'at': upload.created_at}, | ||
'updated': {'at': upload.updated_at}, | ||
}, | ||
'status': upload.status, | ||
} | ||
|
||
|
||
def test_upload_get_and_list_schema_wo_optional_fields(upload_factory): | ||
upload = upload_factory() | ||
serializer = UploadSchema( | ||
id=upload.id, | ||
name=upload.name, | ||
feed={'id': upload.feed_id}, | ||
report={'id': 'RR-123'}, | ||
size=upload.size, | ||
events={ | ||
'created': {'at': upload.created_at}, | ||
'updated': {'at': upload.updated_at}, | ||
}, | ||
status=upload.status, | ||
) | ||
|
||
assert serializer.dict() == { | ||
'id': upload.id, | ||
'feed': {'id': upload.feed_id}, | ||
'report': {'id': 'RR-123'}, | ||
'events': { | ||
'created': {'at': upload.created_at}, | ||
'updated': {'at': upload.updated_at}, | ||
}, | ||
'status': upload.status, | ||
} |