Skip to content

Commit 7036c74

Browse files
committed
fix: pass video_url as list of dicts to entity model
When the `video_url` field is passed to create an entity model from the local config, it should be in a list of dict format. Since the local config provides `video_url` as a list of strings, convert it before sending it to the entity.
1 parent f7f5014 commit 7036c74

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

awsmp/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def entity_list(entity_type, filter_visibility):
7171
@click.argument("entity-id")
7272
def entity_show(entity_id):
7373
details = _driver.get_entity_details(entity_id)
74+
breakpoint()
7475
print(json.dumps(details, indent=2))
7576

7677

awsmp/models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ class PromotionalResourcesModel(BaseModel):
387387
"""
388388

389389
LogoUrl: HttpUrl
390-
Videos: List[dict[str, str]]
390+
Videos: List[dict[str, Any]]
391391
AdditionalResources: YamlSupportResources
392392

393393
@field_validator("AdditionalResources")
@@ -825,7 +825,9 @@ def get_entity_from_yaml(yaml_config: dict[str, Any]) -> EntityModel:
825825
},
826826
"PromotionalResources": {
827827
"LogoUrl": ami_product.description.logourl,
828-
"Videos": ami_product.description.video_urls,
828+
"Videos": [{"Url": ami_product.description.video_urls[-1]}]
829+
if ami_product.description.video_urls
830+
else [],
829831
"AdditionalResources": ami_product.description.additional_resources,
830832
},
831833
"SupportInformation": {

tests/test_models.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,22 @@ def test_yaml_to_entity_version(self, mock_boto3):
532532
entity_model = models.EntityModel.get_entity_from_yaml(local_config)
533533
assert entity_model.Versions.ReleaseNotes == "test_release_notes\n"
534534

535+
def test_yaml_to_entity_video_urls(self, mock_boto3):
536+
with open("./tests/test_config.yaml", "r") as f:
537+
local_config = yaml.safe_load(f)
538+
local_config["product"]["description"]["video_urls"] = ["https://test.com"]
539+
540+
entity_model = models.EntityModel.get_entity_from_yaml(local_config)
541+
assert entity_model.PromotionalResources.Videos == [HttpUrl("https://test.com")]
542+
543+
def test_yaml_to_entity_video_urls_empty(self, mock_boto3):
544+
with open("./tests/test_config.yaml", "r") as f:
545+
local_config = yaml.safe_load(f)
546+
local_config["product"]["description"]["video_urls"] = []
547+
548+
entity_model = models.EntityModel.get_entity_from_yaml(local_config)
549+
assert entity_model.PromotionalResources.Videos == []
550+
535551
def test_yaml_to_entity_term(self, mock_boto3):
536552
with open("./tests/test_config.yaml", "r") as f:
537553
local_config = yaml.safe_load(f)

0 commit comments

Comments
 (0)