Skip to content

Commit

Permalink
LITE-28372: Returning instance id on hub list
Browse files Browse the repository at this point in the history
  • Loading branch information
akodelia committed Aug 9, 2023
1 parent d8cf566 commit f9b0ef6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
10 changes: 8 additions & 2 deletions connect_ext_ppr/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,21 @@ class ProductSchema(NonNullSchema):
icon: Optional[str]


class HubReferenceSchema(NonNullSchema):
id: str
name: str


class HubSchema(NonNullSchema):
id: str
name: str
instance: PrimaryKeyReference


class DeploymentSchema(NonNullSchema):
id: str
product: ProductSchema
hub: HubSchema
hub: HubReferenceSchema
account_id: str
owner: VendorSchema
last_sync_at: datetime
Expand Down Expand Up @@ -155,7 +161,7 @@ class PPRVersionReferenceSchema(NonNullSchema):
class DeploymentReferenceSchema(NonNullSchema):
id: str
product: ProductSchema
hub: HubSchema
hub: HubReferenceSchema


class DeploymentRequestSchema(NonNullSchema):
Expand Down
4 changes: 2 additions & 2 deletions connect_ext_ppr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
DeploymentRequestSchema,
DeploymentSchema,
FileSchema,
HubSchema,
HubReferenceSchema,
MarketplaceSchema,
PPRVersionReferenceSchema,
PPRVersionSchema,
Expand Down Expand Up @@ -223,7 +223,7 @@ def get_deployment_reference_schema(deployment, hub):
product = deployment.product
product_schema = ProductSchema(id=product.id, name=product.name, icon=product.logo)
hub_id = deployment.hub_id
hub_schema = HubSchema(id=hub_id, name=hub['name'])
hub_schema = HubReferenceSchema(id=hub_id, name=hub['name'])
return DeploymentReferenceSchema(id=deployment.id, product=product_schema, hub=hub_schema)


Expand Down
4 changes: 3 additions & 1 deletion connect_ext_ppr/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,9 @@ def list_hubs_by_product(
]
reponse_list = []
for hub in get_hubs(client, hubs_ids):
reponse_list.append(HubSchema(id=hub['id'], name=hub['name']))
reponse_list.append(
HubSchema(id=hub['id'], name=hub['name'], instance={'id': hub['instance']['id']}),
)
return reponse_list

@router.get(
Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def test_hubs_by_product(
)

hubs = [
{'id': dep1.hub_id, 'name': 'An awesome hub'},
{'id': dep2.hub_id, 'name': 'Another awesome hub'},
{'id': dep1.hub_id, 'name': 'An awesome hub', 'instance': {'id': '37624yu2gr-34535rwew'}},
{'id': dep2.hub_id, 'name': 'Another awesome hub', 'instance': {'id': '37624yu2g-1231231'}},
]
mocker.patch('connect_ext_ppr.webapp.get_hubs', side_effect=[hubs])

Expand Down
4 changes: 2 additions & 2 deletions tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Events,
FileReferenceSchema,
FileSchema,
HubSchema,
HubReferenceSchema,
NonNullSchema,
PPRVersionSchema,
ProductSchema,
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_deployment_schema(status):
name='Some',
icon='/media/VA-000-000/PRD-000-000-000/media/PRD-000-000-000-logo_cLqk6Vm.png',
),
hub=HubSchema(
hub=HubReferenceSchema(
id='HB-1111-2222',
name='Hub Hub',
),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_parse_validation_error():


def test_get_hubs(connect_client, client_mocker_factory):
hub = {'id': 'HB-0000-0000', 'name': 'An awesome hub'}
hub = {'id': 'HB-0000-0000', 'name': 'An awesome hub', 'instance': {'id': 'asdqweqr-342rfawr'}}
client_mocker = client_mocker_factory(base_url=connect_client.endpoint)
client_mocker.hubs.filter(R().id.in_([hub['id']])).mock(return_value=[hub])
assert list(get_hubs(connect_client, [hub['id']])) == [hub]
Expand Down

0 comments on commit f9b0ef6

Please sign in to comment.