diff --git a/ingestion/src/metadata/clients/domo_client.py b/ingestion/src/metadata/clients/domo_client.py index 5194eb3dcba..a2c3f2315c4 100644 --- a/ingestion/src/metadata/clients/domo_client.py +++ b/ingestion/src/metadata/clients/domo_client.py @@ -14,7 +14,9 @@ DomoClient source to extract data from DOMO """ import traceback -from typing import Union +from typing import List, Optional, Union + +from pydantic import BaseModel, Extra from metadata.generated.schema.entity.services.connections.dashboard.domoDashboardConnection import ( DomoDashboardConnection, @@ -34,6 +36,58 @@ HEADERS = {"Content-Type": "application/json"} WORKFLOW_URL = "dataprocessing/v1/dataflows" +class DomoBaseModel(BaseModel): + """ + Domo basic configurations + """ + + class Config: + extra = Extra.allow + + id: str + name: str + + +class DomoOwner(BaseModel): + """ + Owner Owner Details + """ + + displayName: str + id: str + + +class DomoDashboardDetails(DomoBaseModel): + """ + Response from Domo API + """ + + cardIds: Optional[List[int]] + collectionIds: Optional[List[int]] + description: Optional[str] + owners: Optional[List[DomoOwner]] + + +class DomoChartMetadataDetails(BaseModel): + """ + Metadata Details in chart + """ + + class Config: + extra = Extra.allow + + chartType: Optional[str] + + +class DomoChartDetails(DomoBaseModel): + """ + Response from Domo API for chart + """ + + metadata: DomoChartMetadataDetails + description: Optional[str] + + class DomoClient: """ Implements the necessary methods to extract @@ -47,6 +101,11 @@ class DomoClient: ], ): self.config = config + self.config.sandboxDomain = ( + self.config.sandboxDomain[:-1] + if self.config.sandboxDomain.endswith("/") + else self.config.sandboxDomain + ) HEADERS.update({"X-DOMO-Developer-Token": self.config.accessToken}) client_config: ClientConfig = ClientConfig( base_url=self.config.sandboxDomain, @@ -56,7 +115,10 @@ class DomoClient: ) self.client = REST(client_config) - def get_chart_details(self, page_id) -> dict: + def get_chart_details(self, page_id) -> Optional[DomoChartDetails]: + """ + Getting chart details for particular page + """ url = ( f"content/v1/cards?urns={page_id}&parts=datasources,dateInfo,library,masonData,metadata," f"metadataOverrides,owners,problems,properties,slicers,subscriptions&includeFiltered=true" @@ -65,23 +127,46 @@ class DomoClient: response = self.client._request( # pylint: disable=protected-access method="GET", path=url, headers=HEADERS ) - return response[0] if len(response) > 0 else None + + if isinstance(response, list) and len(response) > 0: + return DomoChartDetails( + id=response[0]["id"], + name=response[0]["title"], + metadata=DomoChartMetadataDetails( + chartType=response[0].get("metadata", {}).get("chartType", "") + ), + description=response[0].get("description", ""), + ) except Exception as exc: - logger.info(f"Error while getting details for Card {page_id} - {exc}") + logger.warning(f"Error while getting details for Card {page_id} - {exc}") logger.debug(traceback.format_exc()) return None + # def get_owner_details(self, owner_id) -> dict: + def get_pipelines(self): - response = self.client._request( # pylint: disable=protected-access - method="GET", path=WORKFLOW_URL, headers=HEADERS - ) - return response + try: + response = self.client._request( # pylint: disable=protected-access + method="GET", path=WORKFLOW_URL, headers=HEADERS + ) + return response + except Exception as exc: + logger.warning(f"Error while getting pipelines - {exc}") + logger.debug(traceback.format_exc()) + return [] def get_runs(self, workflow_id): - url = f"dataprocessing/v1/dataflows/{workflow_id}/executions?limit=100&offset=0" - response = self.client._request( # pylint: disable=protected-access - method="GET", path=url, headers=HEADERS - ) - return response + try: + url = f"dataprocessing/v1/dataflows/{workflow_id}/executions?limit=100&offset=0" + response = self.client._request( # pylint: disable=protected-access + method="GET", path=url, headers=HEADERS + ) + return response + except Exception as exc: + logger.warning( + f"Error while getting runs for pipeline {workflow_id} - {exc}" + ) + logger.debug(traceback.format_exc()) + return [] diff --git a/ingestion/src/metadata/ingestion/source/dashboard/domodashboard/metadata.py b/ingestion/src/metadata/ingestion/source/dashboard/domodashboard/metadata.py index a6e41b164db..ff3f534a83f 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/domodashboard/metadata.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/domodashboard/metadata.py @@ -17,7 +17,12 @@ from typing import Any, Iterable, List, Optional from pydantic import ValidationError -from metadata.clients.domo_client import DomoClient +from metadata.clients.domo_client import ( + DomoChartDetails, + DomoClient, + DomoDashboardDetails, + DomoOwner, +) from metadata.generated.schema.api.data.createChart import CreateChartRequest from metadata.generated.schema.api.data.createDashboard import CreateDashboardRequest from metadata.generated.schema.api.lineage.addLineage import AddLineageRequest @@ -47,7 +52,7 @@ class DomodashboardSource(DashboardServiceSource): """ config: WorkflowSource - metadata: OpenMetadataConnection + metadata_config: OpenMetadataConnection status: SourceStatus def __init__(self, config: WorkflowSource, metadata_config: OpenMetadataConnection): @@ -64,31 +69,59 @@ class DomodashboardSource(DashboardServiceSource): ) return cls(config, metadata_config) - def get_dashboards_list(self) -> Optional[List[dict]]: + def get_dashboards_list(self) -> Optional[List[DomoDashboardDetails]]: dashboards = self.client.page_list() dashboard_list = [] for dashboard in dashboards: dashboard_detail = self.get_page_details(page_id=dashboard["id"]) - dashboard_list.append(dashboard_detail) + dashboard_list.append( + DomoDashboardDetails( + id=dashboard_detail.id, + name=dashboard_detail.name, + cardIds=dashboard_detail.cardIds, + description=dashboard_detail.description, + owners=dashboard_detail.owners, + collectionIds=dashboard_detail.collectionIds, + ) + ) return dashboard_list - def get_dashboard_name(self, dashboard: Any) -> str: - return dashboard["name"] + def get_dashboard_name(self, dashboard: DomoDashboardDetails) -> str: + return dashboard.name - def get_dashboard_details(self, dashboard: dict) -> dict: + def get_dashboard_details(self, dashboard: DomoDashboardDetails) -> dict: return dashboard + def get_owner_details(self, owners: List[DomoOwner]) -> Optional[EntityReference]: + for owner in owners: + try: + owner_details = self.client.users_get(owner.id) + if owner_details.get("email"): + user = self.metadata.get_user_by_email(owner_details["email"]) + if user: + return EntityReference(id=user["id"], type="user") + logger.debug( + f"No user for found for email {owner_details['email']} in OMD" + ) + except Exception as exc: + logger.warning( + f"Error while getting details of user {owner.displayName} - {exc}" + ) + return None + def yield_dashboard( - self, dashboard_details: dict + self, dashboard_details: DomoDashboardDetails ) -> Iterable[CreateDashboardRequest]: try: - dashboard_url = f"{self.service_connection.sandboxDomain}/page/{dashboard_details['id']}" + dashboard_url = ( + f"{self.service_connection.sandboxDomain}/page/{dashboard_details.id}" + ) yield CreateDashboardRequest( - name=dashboard_details["id"], + name=dashboard_details.id, dashboardUrl=dashboard_url, - displayName=dashboard_details.get("name"), - description=dashboard_details.get("description", ""), + displayName=dashboard_details.name, + description=dashboard_details.description, charts=[ EntityReference(id=chart.id.__root__, type="chart") for chart in self.context.charts @@ -97,81 +130,94 @@ class DomodashboardSource(DashboardServiceSource): id=self.context.dashboard_service.id.__root__, type="dashboardService", ), + owner=self.get_owner_details(dashboard_details.owners), ) except KeyError as err: logger.warning( - f"Error extracting data from {dashboard_details.get('name', 'unknown')} - {err}" + f"Error extracting data from {dashboard_details.name} - {err}" ) logger.debug(traceback.format_exc()) except ValidationError as err: logger.warning( - f"Error building pydantic model for {dashboard_details.get('name', 'unknown')} - {err}" + f"Error building pydantic model for {dashboard_details.name} - {err}" ) logger.debug(traceback.format_exc()) except Exception as err: logger.warning( - f"Wild error ingesting dashboard {dashboard_details.get('name', 'unknown')} - {err}" + f"Wild error ingesting dashboard {dashboard_details.name} - {err}" ) logger.debug(traceback.format_exc()) - def get_page_details(self, page_id): + def get_owners(self, owners: List[dict]) -> List[DomoOwner]: + domo_owner = [] + for owner in owners: + domo_owner.append( + DomoOwner(id=str(owner["id"]), displayName=owner["displayName"]) + ) + + return domo_owner + + def get_page_details(self, page_id) -> Optional[DomoDashboardDetails]: try: pages = self.client.page_get(page_id) - return pages + return DomoDashboardDetails( + name=pages["name"], + id=pages["id"], + cardIds=pages.get("cardIds", []), + description=pages.get("description", ""), + collectionIds=pages.get("collectionIds", []), + owners=self.get_owners(pages.get("owners", [])), + ) except Exception as exc: logger.warning( - f"Error while getting details from collection {page_id} - {exc}" + f"Error while getting details from collection page {page_id} - {exc}" ) logger.debug(traceback.format_exc()) return None def get_chart_ids(self, collection_ids: List[Any]): chart_ids = [] - for collection_id in collection_ids: + for collection_id in collection_ids or []: chart_id = self.get_page_details(page_id=collection_id) - for chart in chart_id.get("cardIds", []): + for chart in chart_id.cardIds: chart_ids.append(chart) return chart_ids def yield_dashboard_chart( - self, dashboard_details: Any + self, dashboard_details: DomoDashboardDetails ) -> Optional[Iterable[CreateChartRequest]]: - chart_ids = dashboard_details["cardIds"] - chart_id_from_collection = self.get_chart_ids( - dashboard_details.get("collectionIds", []) - ) + chart_ids = dashboard_details.cardIds + chart_id_from_collection = self.get_chart_ids(dashboard_details.collectionIds) chart_ids.extend(chart_id_from_collection) for chart_id in chart_ids: try: - chart = self.domo_client.get_chart_details(page_id=chart_id) - + chart: DomoChartDetails = self.domo_client.get_chart_details( + page_id=chart_id + ) chart_url = ( f"{self.service_connection.sandboxDomain}/page/" - f"{dashboard_details['id']}/kpis/details/{chart_id}" + f"{dashboard_details.id}/kpis/details/{chart_id}" ) - if filter_by_chart( - self.source_config.chartFilterPattern, chart["title"] - ): - self.status.filter(chart["title"], "Chart Pattern not allowed") + if filter_by_chart(self.source_config.chartFilterPattern, chart.name): + self.status.filter(chart.name, "Chart Pattern not allowed") continue - - yield CreateChartRequest( - name=chart_id, - description=chart.get("description", ""), - displayName=chart.get("title"), - chartType=get_standard_chart_type( - chart["metadata"].get("chartType", "") - ).value, - chartUrl=chart_url, - service=EntityReference( - id=self.context.dashboard_service.id.__root__, - type="dashboardService", - ), - ) - self.status.scanned(chart["title"]) + if chart.name: + yield CreateChartRequest( + name=chart_id, + description=chart.description, + displayName=chart.name, + chartUrl=chart_url, + service=EntityReference( + id=self.context.dashboard_service.id.__root__, + type="dashboardService", + ), + chartType=get_standard_chart_type(chart.metadata.chartType), + ) + self.status.scanned(chart.name) except Exception as exc: logger.warning(f"Error creating chart [{chart}]: {exc}") + self.status.failures.append(f"{dashboard_details.name}.{chart_id}") logger.debug(traceback.format_exc()) continue diff --git a/ingestion/tests/unit/resources/datasets/domodashboard_dataset.json b/ingestion/tests/unit/resources/datasets/domodashboard_dataset.json index bf26d75a010..7e9d0ba76b9 100644 --- a/ingestion/tests/unit/resources/datasets/domodashboard_dataset.json +++ b/ingestion/tests/unit/resources/datasets/domodashboard_dataset.json @@ -1,770 +1,777 @@ -{ - "id":"552315335", - "page":{ - "pageId":552315335, - "ownerId":1027954122, - "owners":[ - { - "id":1027954122, - "type":"USER", - "displayName":"Nihar Doshi" - } - ], - "type":"page", - "title":"New Dashboard", - "pageName":"New Dashboard", - "created":1665063179000, - "updated":1665144338903, - "locked":false, - "mobileEnabled":true, - "sharedViewPage":true, - "virtualPage":false, - "isOwner":true - }, - "type":"page", - "title":"New Dashboard", - "sizes":[ - { - "id":"1108771657", - "size":"" - }, - { - "id":"2025899139", - "size":"" - }, - { - "id":"1985861713", - "size":"" - } - ], - "cards":[ - { - "metadata":{ - "chartType":"badge_bubble", - "chartVersion":"6", - "currentLabel":"Deals Won in Period", - "allTime":"{\"groupName\":\"Other\",\"name\":\"DEFAULT\",\"type\":\"Other\",\"selected\":true,\"estimatedSeconds\":-1,\"dateLabel\":\"\",\"column\":\"CreatedDate\"}", - "calendar":"default", - "columnAliases":"{\"Owner.Name\":\"Owner.Name\",\"IsWon\":\"IsWon\",\"Amount\":\"Amount\"}", - "columnFormats":"{\"Amount\":{\"type\":\"currency\",\"format\":\"###,###\",\"commas\":true,\"percentMultiplied\":true,\"precision\":0,\"currency\":\"$\",\"percent\":false}}", - "SummaryNumberFormat":"{\"type\":\"number\",\"format\":\"0A\"}" - }, - "drillPathURNs":[ - - ], - "subscriptions":[ - { - "cardId":1108771657, - "dataSourceId":"1eb93e0f-a262-4f62-a948-ad9a52b5d0b5", - "dataSourceName":"Salesforce", - "componentName":"big_number", - "subscription":{ - "name":"big_number", - "dataSourceId":"1eb93e0f-a262-4f62-a948-ad9a52b5d0b5", - "columns":[ - { - "formulaId":"calculation_99429b3c-36eb-40d8-90a5-a59d76e4d242", - "alias":"Deals Won in Period", - "format":{ - "type":"abbreviated", - "format":"0" - } - } - ], - "filters":[ - - ], - "orderBy":[ - - ], - "groupBy":[ - - ], - "fiscal":false, - "projection":false, - "distinct":false, - "limit":1 - }, - "displayType":"sample-data", - "dataType":"publicsampledata", - "providerType":"publicsampledata" - }, - { - "cardId":1108771657, - "dataSourceId":"1eb93e0f-a262-4f62-a948-ad9a52b5d0b5", - "dataSourceName":"Salesforce", - "componentName":"main", - "subscription":{ - "name":"main", - "dataSourceId":"1eb93e0f-a262-4f62-a948-ad9a52b5d0b5", - "columns":[ - { - "column":"IsWon", - "aggregation":"COUNT", - "mapping":"XTIME" - }, - { - "column":"Amount", - "aggregation":"AVG", - "mapping":"VALUE" - }, - { - "column":"Owner.Name", - "mapping":"SERIES" - }, - { - "column":"Amount", - "aggregation":"SUM", - "mapping":"BUBBLESIZE", - "format":{ - "type":"currency", - "format":"###,###", - "commas":true, - "percentMultiplied":true, - "precision":0, - "currency":"$", - "percent":false - } - } - ], - "filters":[ - { - "column":"IsWon", - "values":[ - "true" - ], - "filterType":"LEGACY", - "operand":"IN" - } - ], - "dateRangeFilter":{ - "column":{ - "column":"CreatedDate", - "exprType":"COLUMN" - }, - "dateTimeRange":{ - "dateTimeRangeType":"INTERVAL_OFFSET", - "interval":"QUARTER", - "offset":1, - "count":0 - } - }, - "dateGrain":{ - "column":"CreatedDate" - }, - "orderBy":[ - { - "column":"Amount", - "aggregation":"SUM", - "order":"DESCENDING" - } - ], - "groupBy":[ - { - "column":"Owner.Name" - } - ], - "fiscal":false, - "projection":false, - "distinct":false, - "limit":10 - }, - "displayType":"sample-data", - "dataType":"publicsampledata", - "providerType":"publicsampledata" - } - ], - "owners":[ - { - "id":"27", - "type":"USER", - "displayName":"DomoSupport" - } - ], - "slicers":[ - - ], - "dateInfo":{ - "dateRange":{ - "columnName":"CreatedDate", - "columnDataType":"DATETIME", - "dateRangeFilter":{ - "column":{ - "column":"CreatedDate", - "exprType":"COLUMN" - }, - "dateTimeRange":{ - "dateTimeRangeType":"INTERVAL_OFFSET", - "interval":"QUARTER", - "offset":1, - "count":0 - } - } - }, - "dateGrain":{ - "columnName":"CreatedDate", - "columnDataType":"DATETIME" - } - }, - "datasources":[ - { - "dataSourceId":"1eb93e0f-a262-4f62-a948-ad9a52b5d0b5", - "dataSourceName":"Salesforce", - "displayType":"sample-data", - "dataType":"publicsampledata", - "providerType":"publicsampledata", - "isSampleData":true, - "lastUpdated":"None", - "adc":false, - "phase":"None", - "state":"IDLE" - } - ], - "certification":{ - "state":"NOT_CERTIFIED", - "adminCertified":false - }, - "urn":"1108771657", - "id":1108771657, - "type":"kpi", - "created":1663152634, - "badgeUpdated":1663152634000, - "creatorId":27, - "ownerId":27, - "description":"TOP SALESPEOPLE\nDisplays the top 10 salespeople by won revenue. Identify over-performers and understand the secrets to their success.", - "title":"Top Salespeople", - "active":true, - "allowTableDrill":true, - "locked":false, - "access":true, - "isCurrentUserOwner":false - }, - { - "metadata":{ - "chartType":"badge_vert_stackedbar", - "chartVersion":"9", - "currentLabel":"Sum of customer_id", - "historyId":"85648f16-52ca-4a3d-9516-bf3298715a2e", - "calendar":"default", - "columnAliases":"{}", - "columnFormats":"{}", - "SummaryNumberFormat":"{\"type\":\"number\",\"format\":\"#A\"}", - "dynamicTitle":"{\"text\":[{\"text\":\"Milan Datasets\",\"type\":\"TEXT\"}]}", - "dynamicDescription":"{\"text\":[],\"displayOnCardDetails\":true}" - }, - "drillPathURNs":[ - - ], - "subscriptions":[ - { - "cardId":1985861713, - "dataSourceId":"2e41e76b-fc02-480d-a932-91bdbea40fe5", - "dataSourceName":"Milan Datasets", - "componentName":"big_number", - "subscription":{ - "name":"big_number", - "dataSourceId":"2e41e76b-fc02-480d-a932-91bdbea40fe5", - "columns":[ - { - "column":"customer_id", - "aggregation":"SUM", - "alias":"Sum of customer_id", - "format":{ - "type":"abbreviated", - "format":"#" - } - } - ], - "filters":[ - - ], - "orderBy":[ - - ], - "groupBy":[ - - ], - "fiscal":false, - "projection":false, - "distinct":false, - "limit":1 - }, - "displayType":"amazon-redshift", - "dataType":"amazon-redshift", - "providerType":"amazon-redshift" - }, - { - "cardId":1985861713, - "dataSourceId":"2e41e76b-fc02-480d-a932-91bdbea40fe5", - "dataSourceName":"Milan Datasets", - "componentName":"main", - "subscription":{ - "name":"main", - "dataSourceId":"2e41e76b-fc02-480d-a932-91bdbea40fe5", - "columns":[ - { - "column":"customer_lifetime_value", - "mapping":"ITEM" - }, - { - "column":"customer_id", - "aggregation":"SUM", - "mapping":"VALUE" - } - ], - "filters":[ - - ], - "orderBy":[ - - ], - "groupBy":[ - { - "column":"customer_lifetime_value" - } - ], - "fiscal":false, - "projection":false, - "distinct":false - }, - "displayType":"amazon-redshift", - "dataType":"amazon-redshift", - "providerType":"amazon-redshift" - } - ], - "owners":[ - { - "id":"1027954122", - "type":"USER", - "displayName":"Nihar Doshi" - } - ], - "slicers":[ - - ], - "dateInfo":{ - - }, - "datasources":[ - { - "dataSourceId":"2e41e76b-fc02-480d-a932-91bdbea40fe5", - "dataSourceName":"Milan Datasets", - "displayType":"amazon-redshift", - "dataType":"amazon-redshift", - "providerType":"amazon-redshift", - "isSampleData":false, - "lastUpdated":1665488105556, - "adc":false, - "phase":"None", - "state":"SUCCESS" - } - ], - "certification":{ - "state":"NOT_CERTIFIED", - "adminCertified":false - }, - "urn":"1985861713", - "id":1985861713, - "type":"kpi", - "created":1665144309, - "badgeUpdated":1665144311000, - "creatorId":1027954122, - "ownerId":1027954122, - "title":"Milan Datasets", - "active":true, - "allowTableDrill":true, - "locked":false, - "access":true, - "isCurrentUserOwner":true - }, - { - "metadata":{ - "chartType":"badge_vert_multibar", - "currentLabel":"New Page Fans in Period", - "currentMethod":"", - "source":"drillView", - "title":"Page Fans", - "calendar":"default", - "columnAliases":"{\"Unique Fan Adds\":\"New Page Fans\",\"Unique Fan Removes\":\"Fan Removes\"}", - "columnFormats":"{}", - "goal":"", - "seriesInColumns":"true", - "kpiType":"drill_view", - "SummaryNumberFormat":"{\"type\":\"number\",\"format\":\"#,##0\"}", - "usingSampleData":"" - }, - "drillPathURNs":[ - - ], - "subscriptions":[ - { - "cardId":2025899139, - "dataSourceId":"eb319fef-58ee-4dcb-986d-90a885269bc6", - "dataSourceName":"Page Impressions Details", - "componentName":"big_number", - "subscription":{ - "name":"big_number", - "dataSourceId":"eb319fef-58ee-4dcb-986d-90a885269bc6", - "columns":[ - { - "column":"Unique Fan Adds", - "aggregation":"SUM", - "distinct":false, - "alias":"New Page Fans in Period", - "format":{ - "type":"number", - "format":"#,##0" - } - } - ], - "filters":[ - - ], - "orderBy":[ - - ], - "groupBy":[ - - ], - "fiscal":false, - "projection":false, - "distinct":false, - "limit":1 - }, - "displayType":"sample-data", - "dataType":"publicsampledata", - "providerType":"publicsampledata" - }, - { - "cardId":2025899139, - "dataSourceId":"eb319fef-58ee-4dcb-986d-90a885269bc6", - "dataSourceName":"Page Impressions Details", - "componentName":"main", - "subscription":{ - "name":"main", - "dataSourceId":"eb319fef-58ee-4dcb-986d-90a885269bc6", - "columns":[ - { - "column":"Date", - "calendar":true, - "mapping":"ITEM", - "alias":"Date" - }, - { - "column":"Unique Fan Adds", - "aggregation":"SUM", - "distinct":false, - "mapping":"SERIES", - "alias":"New Page Fans" - }, - { - "column":"Unique Fan Removes", - "aggregation":"SUM", - "distinct":false, - "mapping":"SERIES", - "alias":"Fan Removes" - } - ], - "filters":[ - - ], - "dateGrain":{ - "column":"Date", - "dateTimeElement":"DAY" - }, - "orderBy":[ - - ], - "groupBy":[ - { - "column":"Date", - "calendar":true - } - ], - "fiscal":false, - "projection":false, - "distinct":false - }, - "displayType":"sample-data", - "dataType":"publicsampledata", - "providerType":"publicsampledata" - } - ], - "owners":[ - { - "id":"27", - "type":"USER", - "displayName":"DomoSupport" - } - ], - "slicers":[ - - ], - "dateInfo":{ - "dateRange":{ - "columnName":"Date", - "columnDataType":"DATETIME" - }, - "dateGrain":{ - "dateTimeElement":"DAY", - "columnName":"Date", - "columnDataType":"DATETIME" - } - }, - "datasources":[ - { - "dataSourceId":"eb319fef-58ee-4dcb-986d-90a885269bc6", - "dataSourceName":"Page Impressions Details", - "displayType":"sample-data", - "dataType":"publicsampledata", - "providerType":"publicsampledata", - "isSampleData":true, - "lastUpdated":"None", - "adc":false, - "phase":"None", - "state":"IDLE" - } - ], - "certification":{ - "state":"NOT_CERTIFIED", - "adminCertified":false - }, - "urn":"2025899139", - "id":2025899139, - "type":"kpi", - "created":1663152648, - "badgeUpdated":1663152648000, - "creatorId":27, - "ownerId":27, - "description":"", - "title":"Page Fans", - "active":true, - "allowTableDrill":true, - "locked":false, - "access":true, - "isCurrentUserOwner":false - } - ], - "collections":[ - - ], - "locked":false, - "pageLayoutV4":{ - "layoutId":1733626331, - "pageUrn":"552315335", - "printFriendly":true, - "enabled":true, - "isDynamic":false, - "hasPageBreaks":false, - "content":[ - { - "type":"HEADER", - "contentKey":1, - "text":"Appendix", - "hideTitle":false, - "hideDescription":true, - "hideSummary":false, - "summaryNumberOnly":false, - "hideTimeframe":false, - "hideFooter":false, - "hideWrench":false, - "hideMargins":false, - "hasSummary":false, - "fitToFrame":false, - "hideBorder":false, - "acceptFilters":true, - "acceptDateFilter":true, - "acceptSegments":true, - "compactInteractionDefault":true - }, - { - "type":"CARD", - "contentKey":2, - "cardId":1108771657, - "cardUrn":"1108771657", - "hideTitle":false, - "hideDescription":true, - "hideSummary":false, - "summaryNumberOnly":false, - "hideTimeframe":false, - "hideFooter":true, - "hideWrench":false, - "hideMargins":false, - "hasSummary":true, - "fitToFrame":false, - "hideBorder":false, - "acceptFilters":true, - "acceptDateFilter":true, - "acceptSegments":true, - "compactInteractionDefault":true - }, - { - "type":"CARD", - "contentKey":3, - "cardId":2025899139, - "cardUrn":"2025899139", - "hideTitle":false, - "hideDescription":true, - "hideSummary":false, - "summaryNumberOnly":false, - "hideTimeframe":false, - "hideFooter":true, - "hideWrench":false, - "hideMargins":false, - "hasSummary":true, - "fitToFrame":false, - "hideBorder":false, - "acceptFilters":true, - "acceptDateFilter":true, - "acceptSegments":true, - "compactInteractionDefault":true - }, - { - "type":"CARD", - "contentKey":4, - "cardId":1985861713, - "cardUrn":"1985861713", - "hideTitle":false, - "hideDescription":true, - "hideSummary":false, - "summaryNumberOnly":false, - "hideTimeframe":false, - "hideFooter":true, - "hideWrench":false, - "hideMargins":false, - "hasSummary":true, - "fitToFrame":false, - "hideBorder":false, - "acceptFilters":true, - "acceptDateFilter":true, - "acceptSegments":true, - "compactInteractionDefault":true - } - ], - "standard":{ - "aspectRatio":1.67, - "width":60, - "type":"STANDARD", - "template":[ - { - "contentKey":0, - "x":0, - "y":0, - "width":60, - "height":3, - "type":"SEPARATOR", - "virtual":true, - "virtualAppendix":true - }, - { - "contentKey":1, - "x":0, - "y":3, - "width":60, - "height":5, - "type":"HEADER", - "virtual":true, - "virtualAppendix":true - }, - { - "contentKey":2, - "x":0, - "y":8, - "width":15, - "height":30, - "type":"CARD", - "virtual":true, - "virtualAppendix":true - }, - { - "contentKey":3, - "x":15, - "y":8, - "width":15, - "height":30, - "type":"CARD", - "virtual":true, - "virtualAppendix":true - }, - { - "contentKey":4, - "x":30, - "y":8, - "width":15, - "height":30, - "type":"CARD", - "virtual":true, - "virtualAppendix":true - } - ] - }, - "compact":{ - "aspectRatio":1.0, - "width":12, - "type":"COMPACT", - "template":[ - { - "contentKey":0, - "x":0, - "y":0, - "width":12, - "height":1, - "type":"SEPARATOR", - "virtual":true, - "virtualAppendix":true - }, - { - "contentKey":1, - "x":0, - "y":1, - "width":12, - "height":2, - "type":"HEADER", - "virtual":true, - "virtualAppendix":true - }, - { - "contentKey":2, - "x":0, - "y":3, - "width":6, - "height":6, - "type":"CARD", - "virtual":true, - "virtualAppendix":true - }, - { - "contentKey":3, - "x":6, - "y":3, - "width":6, - "height":6, - "type":"CARD", - "virtual":true, - "virtualAppendix":true - }, - { - "contentKey":4, - "x":0, - "y":9, - "width":6, - "height":6, - "type":"CARD", - "virtual":true, - "virtualAppendix":true - } - ] - }, - "background":"None" - }, - "isFavorite":false, - "pageAnalyzerSettings":{ - "pageId":552315335, - "interactionFilters":false, - "noAddingNewFilters":false, - "showFilterBar":true, - "showGlobalDateFilters":true, - "showSegments":true, - "showFilterIcons":true - } - } \ No newline at end of file +[ + [ + { + "id":"552315335", + "page":{ + "pageId":552315335, + "ownerId":1027954122, + "owners":[ + { + "id":1027954122, + "type":"USER", + "displayName":"Nihar Doshi" + } + ], + "type":"page", + "title":"New Dashboard", + "pageName":"New Dashboard", + "created":1665063179000, + "updated":1665144338903, + "locked":false, + "mobileEnabled":true, + "sharedViewPage":true, + "virtualPage":false, + "isOwner":true + }, + "type":"page", + "title":"New Dashboard", + "description": "TOP SALESPEOPLE\nDisplays the top 10 salespeople by won revenue. Identify over-performers and understand the secrets to their success.", + "sizes":[ + { + "id":"1108771657", + "size":"" + }, + { + "id":"2025899139", + "size":"" + }, + { + "id":"1985861713", + "size":"" + } + ], + "cards":[ + { + "metadata":{ + "chartType":"badge_bubble", + "chartVersion":"6", + "currentLabel":"Deals Won in Period", + "allTime":"{\"groupName\":\"Other\",\"name\":\"DEFAULT\",\"type\":\"Other\",\"selected\":true,\"estimatedSeconds\":-1,\"dateLabel\":\"\",\"column\":\"CreatedDate\"}", + "calendar":"default", + "columnAliases":"{\"Owner.Name\":\"Owner.Name\",\"IsWon\":\"IsWon\",\"Amount\":\"Amount\"}", + "columnFormats":"{\"Amount\":{\"type\":\"currency\",\"format\":\"###,###\",\"commas\":true,\"percentMultiplied\":true,\"precision\":0,\"currency\":\"$\",\"percent\":false}}", + "SummaryNumberFormat":"{\"type\":\"number\",\"format\":\"0A\"}" + }, + "drillPathURNs":[ + + ], + "subscriptions":[ + { + "cardId":1108771657, + "dataSourceId":"1eb93e0f-a262-4f62-a948-ad9a52b5d0b5", + "dataSourceName":"Salesforce", + "componentName":"big_number", + "subscription":{ + "name":"big_number", + "dataSourceId":"1eb93e0f-a262-4f62-a948-ad9a52b5d0b5", + "columns":[ + { + "formulaId":"calculation_99429b3c-36eb-40d8-90a5-a59d76e4d242", + "alias":"Deals Won in Period", + "format":{ + "type":"abbreviated", + "format":"0" + } + } + ], + "filters":[ + + ], + "orderBy":[ + + ], + "groupBy":[ + + ], + "fiscal":false, + "projection":false, + "distinct":false, + "limit":1 + }, + "displayType":"sample-data", + "dataType":"publicsampledata", + "providerType":"publicsampledata" + }, + { + "cardId":1108771657, + "dataSourceId":"1eb93e0f-a262-4f62-a948-ad9a52b5d0b5", + "dataSourceName":"Salesforce", + "componentName":"main", + "subscription":{ + "name":"main", + "dataSourceId":"1eb93e0f-a262-4f62-a948-ad9a52b5d0b5", + "columns":[ + { + "column":"IsWon", + "aggregation":"COUNT", + "mapping":"XTIME" + }, + { + "column":"Amount", + "aggregation":"AVG", + "mapping":"VALUE" + }, + { + "column":"Owner.Name", + "mapping":"SERIES" + }, + { + "column":"Amount", + "aggregation":"SUM", + "mapping":"BUBBLESIZE", + "format":{ + "type":"currency", + "format":"###,###", + "commas":true, + "percentMultiplied":true, + "precision":0, + "currency":"$", + "percent":false + } + } + ], + "filters":[ + { + "column":"IsWon", + "values":[ + "true" + ], + "filterType":"LEGACY", + "operand":"IN" + } + ], + "dateRangeFilter":{ + "column":{ + "column":"CreatedDate", + "exprType":"COLUMN" + }, + "dateTimeRange":{ + "dateTimeRangeType":"INTERVAL_OFFSET", + "interval":"QUARTER", + "offset":1, + "count":0 + } + }, + "dateGrain":{ + "column":"CreatedDate" + }, + "orderBy":[ + { + "column":"Amount", + "aggregation":"SUM", + "order":"DESCENDING" + } + ], + "groupBy":[ + { + "column":"Owner.Name" + } + ], + "fiscal":false, + "projection":false, + "distinct":false, + "limit":10 + }, + "displayType":"sample-data", + "dataType":"publicsampledata", + "providerType":"publicsampledata" + } + ], + "owners":[ + { + "id":"27", + "type":"USER", + "displayName":"DomoSupport" + } + ], + "slicers":[ + + ], + "dateInfo":{ + "dateRange":{ + "columnName":"CreatedDate", + "columnDataType":"DATETIME", + "dateRangeFilter":{ + "column":{ + "column":"CreatedDate", + "exprType":"COLUMN" + }, + "dateTimeRange":{ + "dateTimeRangeType":"INTERVAL_OFFSET", + "interval":"QUARTER", + "offset":1, + "count":0 + } + } + }, + "dateGrain":{ + "columnName":"CreatedDate", + "columnDataType":"DATETIME" + } + }, + "datasources":[ + { + "dataSourceId":"1eb93e0f-a262-4f62-a948-ad9a52b5d0b5", + "dataSourceName":"Salesforce", + "displayType":"sample-data", + "dataType":"publicsampledata", + "providerType":"publicsampledata", + "isSampleData":true, + "lastUpdated":"None", + "adc":false, + "phase":"None", + "state":"IDLE" + } + ], + "certification":{ + "state":"NOT_CERTIFIED", + "adminCertified":false + }, + "urn":"1108771657", + "id":1108771657, + "type":"kpi", + "created":1663152634, + "badgeUpdated":1663152634000, + "creatorId":27, + "ownerId":27, + "description":"TOP SALESPEOPLE\nDisplays the top 10 salespeople by won revenue. Identify over-performers and understand the secrets to their success.", + "title":"Top Salespeople", + "active":true, + "allowTableDrill":true, + "locked":false, + "access":true, + "isCurrentUserOwner":false + }, + { + "metadata":{ + "chartType":"badge_vert_stackedbar", + "chartVersion":"9", + "currentLabel":"Sum of customer_id", + "historyId":"85648f16-52ca-4a3d-9516-bf3298715a2e", + "calendar":"default", + "columnAliases":"{}", + "columnFormats":"{}", + "SummaryNumberFormat":"{\"type\":\"number\",\"format\":\"#A\"}", + "dynamicTitle":"{\"text\":[{\"text\":\"Milan Datasets\",\"type\":\"TEXT\"}]}", + "dynamicDescription":"{\"text\":[],\"displayOnCardDetails\":true}" + }, + "drillPathURNs":[ + + ], + "subscriptions":[ + { + "cardId":1985861713, + "dataSourceId":"2e41e76b-fc02-480d-a932-91bdbea40fe5", + "dataSourceName":"Milan Datasets", + "componentName":"big_number", + "subscription":{ + "name":"big_number", + "dataSourceId":"2e41e76b-fc02-480d-a932-91bdbea40fe5", + "columns":[ + { + "column":"customer_id", + "aggregation":"SUM", + "alias":"Sum of customer_id", + "format":{ + "type":"abbreviated", + "format":"#" + } + } + ], + "filters":[ + + ], + "orderBy":[ + + ], + "groupBy":[ + + ], + "fiscal":false, + "projection":false, + "distinct":false, + "limit":1 + }, + "displayType":"amazon-redshift", + "dataType":"amazon-redshift", + "providerType":"amazon-redshift" + }, + { + "cardId":1985861713, + "dataSourceId":"2e41e76b-fc02-480d-a932-91bdbea40fe5", + "dataSourceName":"Milan Datasets", + "componentName":"main", + "subscription":{ + "name":"main", + "dataSourceId":"2e41e76b-fc02-480d-a932-91bdbea40fe5", + "columns":[ + { + "column":"customer_lifetime_value", + "mapping":"ITEM" + }, + { + "column":"customer_id", + "aggregation":"SUM", + "mapping":"VALUE" + } + ], + "filters":[ + + ], + "orderBy":[ + + ], + "groupBy":[ + { + "column":"customer_lifetime_value" + } + ], + "fiscal":false, + "projection":false, + "distinct":false + }, + "displayType":"amazon-redshift", + "dataType":"amazon-redshift", + "providerType":"amazon-redshift" + } + ], + "owners":[ + { + "id":"1027954122", + "type":"USER", + "displayName":"Nihar Doshi" + } + ], + "slicers":[ + + ], + "dateInfo":{ + + }, + "datasources":[ + { + "dataSourceId":"2e41e76b-fc02-480d-a932-91bdbea40fe5", + "dataSourceName":"Milan Datasets", + "displayType":"amazon-redshift", + "dataType":"amazon-redshift", + "providerType":"amazon-redshift", + "isSampleData":false, + "lastUpdated":1665488105556, + "adc":false, + "phase":"None", + "state":"SUCCESS" + } + ], + "certification":{ + "state":"NOT_CERTIFIED", + "adminCertified":false + }, + "urn":"1985861713", + "id":1985861713, + "type":"kpi", + "created":1665144309, + "badgeUpdated":1665144311000, + "creatorId":1027954122, + "ownerId":1027954122, + "title":"Milan Datasets", + "active":true, + "allowTableDrill":true, + "locked":false, + "access":true, + "isCurrentUserOwner":true + }, + { + "metadata":{ + "chartType":"badge_vert_multibar", + "currentLabel":"New Page Fans in Period", + "currentMethod":"", + "source":"drillView", + "title":"Page Fans", + "calendar":"default", + "columnAliases":"{\"Unique Fan Adds\":\"New Page Fans\",\"Unique Fan Removes\":\"Fan Removes\"}", + "columnFormats":"{}", + "goal":"", + "seriesInColumns":"true", + "kpiType":"drill_view", + "SummaryNumberFormat":"{\"type\":\"number\",\"format\":\"#,##0\"}", + "usingSampleData":"" + }, + "drillPathURNs":[ + + ], + "subscriptions":[ + { + "cardId":2025899139, + "dataSourceId":"eb319fef-58ee-4dcb-986d-90a885269bc6", + "dataSourceName":"Page Impressions Details", + "componentName":"big_number", + "subscription":{ + "name":"big_number", + "dataSourceId":"eb319fef-58ee-4dcb-986d-90a885269bc6", + "columns":[ + { + "column":"Unique Fan Adds", + "aggregation":"SUM", + "distinct":false, + "alias":"New Page Fans in Period", + "format":{ + "type":"number", + "format":"#,##0" + } + } + ], + "filters":[ + + ], + "orderBy":[ + + ], + "groupBy":[ + + ], + "fiscal":false, + "projection":false, + "distinct":false, + "limit":1 + }, + "displayType":"sample-data", + "dataType":"publicsampledata", + "providerType":"publicsampledata" + }, + { + "cardId":2025899139, + "dataSourceId":"eb319fef-58ee-4dcb-986d-90a885269bc6", + "dataSourceName":"Page Impressions Details", + "componentName":"main", + "subscription":{ + "name":"main", + "dataSourceId":"eb319fef-58ee-4dcb-986d-90a885269bc6", + "columns":[ + { + "column":"Date", + "calendar":true, + "mapping":"ITEM", + "alias":"Date" + }, + { + "column":"Unique Fan Adds", + "aggregation":"SUM", + "distinct":false, + "mapping":"SERIES", + "alias":"New Page Fans" + }, + { + "column":"Unique Fan Removes", + "aggregation":"SUM", + "distinct":false, + "mapping":"SERIES", + "alias":"Fan Removes" + } + ], + "filters":[ + + ], + "dateGrain":{ + "column":"Date", + "dateTimeElement":"DAY" + }, + "orderBy":[ + + ], + "groupBy":[ + { + "column":"Date", + "calendar":true + } + ], + "fiscal":false, + "projection":false, + "distinct":false + }, + "displayType":"sample-data", + "dataType":"publicsampledata", + "providerType":"publicsampledata" + } + ], + "owners":[ + { + "id":"27", + "type":"USER", + "displayName":"DomoSupport" + } + ], + "slicers":[ + + ], + "dateInfo":{ + "dateRange":{ + "columnName":"Date", + "columnDataType":"DATETIME" + }, + "dateGrain":{ + "dateTimeElement":"DAY", + "columnName":"Date", + "columnDataType":"DATETIME" + } + }, + "datasources":[ + { + "dataSourceId":"eb319fef-58ee-4dcb-986d-90a885269bc6", + "dataSourceName":"Page Impressions Details", + "displayType":"sample-data", + "dataType":"publicsampledata", + "providerType":"publicsampledata", + "isSampleData":true, + "lastUpdated":"None", + "adc":false, + "phase":"None", + "state":"IDLE" + } + ], + "certification":{ + "state":"NOT_CERTIFIED", + "adminCertified":false + }, + "urn":"2025899139", + "id":2025899139, + "type":"kpi", + "created":1663152648, + "badgeUpdated":1663152648000, + "creatorId":27, + "ownerId":27, + "description":"", + "title":"Page Fans", + "active":true, + "allowTableDrill":true, + "locked":false, + "access":true, + "isCurrentUserOwner":false + } + ], + "collections":[ + + ], + "locked":false, + "pageLayoutV4":{ + "layoutId":1733626331, + "pageUrn":"552315335", + "printFriendly":true, + "enabled":true, + "isDynamic":false, + "hasPageBreaks":false, + "content":[ + { + "type":"HEADER", + "contentKey":1, + "text":"Appendix", + "hideTitle":false, + "hideDescription":true, + "hideSummary":false, + "summaryNumberOnly":false, + "hideTimeframe":false, + "hideFooter":false, + "hideWrench":false, + "hideMargins":false, + "hasSummary":false, + "fitToFrame":false, + "hideBorder":false, + "acceptFilters":true, + "acceptDateFilter":true, + "acceptSegments":true, + "compactInteractionDefault":true + }, + { + "type":"CARD", + "contentKey":2, + "cardId":1108771657, + "cardUrn":"1108771657", + "hideTitle":false, + "hideDescription":true, + "hideSummary":false, + "summaryNumberOnly":false, + "hideTimeframe":false, + "hideFooter":true, + "hideWrench":false, + "hideMargins":false, + "hasSummary":true, + "fitToFrame":false, + "hideBorder":false, + "acceptFilters":true, + "acceptDateFilter":true, + "acceptSegments":true, + "compactInteractionDefault":true + }, + { + "type":"CARD", + "contentKey":3, + "cardId":2025899139, + "cardUrn":"2025899139", + "hideTitle":false, + "hideDescription":true, + "hideSummary":false, + "summaryNumberOnly":false, + "hideTimeframe":false, + "hideFooter":true, + "hideWrench":false, + "hideMargins":false, + "hasSummary":true, + "fitToFrame":false, + "hideBorder":false, + "acceptFilters":true, + "acceptDateFilter":true, + "acceptSegments":true, + "compactInteractionDefault":true + }, + { + "type":"CARD", + "contentKey":4, + "cardId":1985861713, + "cardUrn":"1985861713", + "hideTitle":false, + "hideDescription":true, + "hideSummary":false, + "summaryNumberOnly":false, + "hideTimeframe":false, + "hideFooter":true, + "hideWrench":false, + "hideMargins":false, + "hasSummary":true, + "fitToFrame":false, + "hideBorder":false, + "acceptFilters":true, + "acceptDateFilter":true, + "acceptSegments":true, + "compactInteractionDefault":true + } + ], + "standard":{ + "aspectRatio":1.67, + "width":60, + "type":"STANDARD", + "template":[ + { + "contentKey":0, + "x":0, + "y":0, + "width":60, + "height":3, + "type":"SEPARATOR", + "virtual":true, + "virtualAppendix":true + }, + { + "contentKey":1, + "x":0, + "y":3, + "width":60, + "height":5, + "type":"HEADER", + "virtual":true, + "virtualAppendix":true + }, + { + "contentKey":2, + "x":0, + "y":8, + "width":15, + "height":30, + "type":"CARD", + "virtual":true, + "virtualAppendix":true + }, + { + "contentKey":3, + "x":15, + "y":8, + "width":15, + "height":30, + "type":"CARD", + "virtual":true, + "virtualAppendix":true + }, + { + "contentKey":4, + "x":30, + "y":8, + "width":15, + "height":30, + "type":"CARD", + "virtual":true, + "virtualAppendix":true + } + ] + }, + "compact":{ + "aspectRatio":1.0, + "width":12, + "type":"COMPACT", + "template":[ + { + "contentKey":0, + "x":0, + "y":0, + "width":12, + "height":1, + "type":"SEPARATOR", + "virtual":true, + "virtualAppendix":true + }, + { + "contentKey":1, + "x":0, + "y":1, + "width":12, + "height":2, + "type":"HEADER", + "virtual":true, + "virtualAppendix":true + }, + { + "contentKey":2, + "x":0, + "y":3, + "width":6, + "height":6, + "type":"CARD", + "virtual":true, + "virtualAppendix":true + }, + { + "contentKey":3, + "x":6, + "y":3, + "width":6, + "height":6, + "type":"CARD", + "virtual":true, + "virtualAppendix":true + }, + { + "contentKey":4, + "x":0, + "y":9, + "width":6, + "height":6, + "type":"CARD", + "virtual":true, + "virtualAppendix":true + } + ] + }, + "background":"None" + }, + "isFavorite":false, + "pageAnalyzerSettings":{ + "pageId":552315335, + "interactionFilters":false, + "noAddingNewFilters":false, + "showFilterBar":true, + "showGlobalDateFilters":true, + "showSegments":true, + "showFilterIcons":true + } + } + ], + "Reponse[301]", + {} +] \ No newline at end of file diff --git a/ingestion/tests/unit/topology/dashboard/test_domodashboard.py b/ingestion/tests/unit/topology/dashboard/test_domodashboard.py index 4699692b902..7f908ff35c0 100644 --- a/ingestion/tests/unit/topology/dashboard/test_domodashboard.py +++ b/ingestion/tests/unit/topology/dashboard/test_domodashboard.py @@ -19,7 +19,9 @@ from metadata.generated.schema.metadataIngestion.workflow import ( OpenMetadataWorkflowConfig, ) from metadata.generated.schema.type.entityReference import EntityReference +from metadata.ingestion.ometa.client import REST from metadata.ingestion.source.dashboard.domodashboard.metadata import ( + DomoDashboardDetails, DomodashboardSource, ) @@ -83,16 +85,18 @@ mock_domopipeline_config = { }, } -MOCK_DASHBOARD = { - "id": 552315335, - "name": "New Dashboard", - "children": [], - "cardIds": ["1982511286", "781210736"], -} +MOCK_DASHBOARD = DomoDashboardDetails( + id=552315335, + name="New Dashboard", + cardIds=["1982511286", "781210736"], + collection_ids=[], + owners=[], +) + EXPECTED_DASHBOARD = CreateDashboardRequest( name="552315335", displayName="New Dashboard", - description="", + description=None, dashboardUrl="https://domain.domo.com/page/552315335", charts=[], tags=None, @@ -110,16 +114,16 @@ EXPECTED_DASHBOARD = CreateDashboardRequest( extension=None, ) -EXPECTED_DASHBOARDS = [ +EXPECTED_CHARTS = [ CreateChartRequest( - name="Top Salespeople", - displayName="Top Salespeople", + name="1982511286", + displayName="New Dashboard", description=( "TOP SALESPEOPLE\nDisplays the top 10 salespeople by won revenue." " Identify over-performers and understand the secrets to their success." ), chartType="Other", - chartUrl="https://domain.domo.com/page/552315335/kpis/details/1108771657", + chartUrl="https://domain.domo.com/page/552315335/kpis/details/1982511286", tables=None, tags=None, owner=None, @@ -135,31 +139,14 @@ EXPECTED_DASHBOARDS = [ ), ), CreateChartRequest( - name="Milan Datasets", - displayName="Milan Datasets", - description="", - chartType="Other", - chartUrl="https://domain.domo.com/page/552315335/kpis/details/1985861713", - tables=None, - tags=None, - owner=None, - service=EntityReference( - id="c3eb265f-5445-4ad3-ba5e-797d3a3071bb", - type="dashboardService", - name=None, - fullyQualifiedName=None, - description=None, - displayName=None, - deleted=None, - href=None, + name="781210736", + displayName="New Dashboard", + description=( + "TOP SALESPEOPLE\nDisplays the top 10 salespeople by won revenue." + " Identify over-performers and understand the secrets to their success." ), - ), - CreateChartRequest( - name="Page Fans", - displayName="Page Fans", - description="", chartType="Other", - chartUrl="https://domain.domo.com/page/552315335/kpis/details/2025899139", + chartUrl="https://domain.domo.com/page/552315335/kpis/details/781210736", tables=None, tags=None, owner=None, @@ -211,16 +198,38 @@ class DomoDashboardUnitTest(TestCase): def test_dashboard_name(self): assert ( - self.domodashboard.get_dashboard_name(MOCK_DASHBOARD) == mock_data["title"] + self.domodashboard.get_dashboard_name(MOCK_DASHBOARD) + == mock_data[0][0]["title"] ) - @patch("metadata.clients.domo_client.DomoClient.get_chart_details") - def test_chart(self, get_chart_details): - get_chart_details.return_value = mock_data - results = self.domodashboard.yield_dashboard_chart(MOCK_DASHBOARD) - chart_list = [] - for result in results: - if isinstance(result, CreateChartRequest): - chart_list.append(result) - for _, (expected, original) in enumerate(zip(EXPECTED_DASHBOARDS, chart_list)): - self.assertEqual(expected, original) + def test_chart(self): + """ + Function for testing charts + """ + with patch.object(REST, "_request", return_value=mock_data[0]): + results = self.domodashboard.yield_dashboard_chart(MOCK_DASHBOARD) + chart_list = [] + for result in results: + if isinstance(result, CreateChartRequest): + chart_list.append(result) + for _, (expected, original) in enumerate(zip(EXPECTED_CHARTS, chart_list)): + self.assertEqual(expected, original) + + with patch.object(REST, "_request", return_value=mock_data[1]): + result = self.domodashboard.domo_client.get_chart_details( + MOCK_DASHBOARD.cardIds[0] + ) + assert ( + self.domodashboard.domo_client.get_chart_details( + MOCK_DASHBOARD.cardIds[0] + ) + is None + ) + + with patch.object(REST, "_request", return_value=mock_data[2]): + assert ( + self.domodashboard.domo_client.get_chart_details( + MOCK_DASHBOARD.cardIds[0] + ) + is None + )