Skip to content

Commit

Permalink
fix(tableau-exposer-crawler): addressing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samanmasarat committed Jan 15, 2024
1 parent 2e69704 commit 088cfe0
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions tests/_integration/test_tableau_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def mock_graphql_custom_sql_result():
},
{
'query': "select * from sample_db.public.customers left join "
"sample_db.public.orders on customers.id = orders.customer_id",
"sample_db.public.orders on customers.id = orders.customer_id",
'name': 'Custom SQL Query',
'isEmbedded': None,
'database': {'name': 'SAMPLE_DB', 'connectionType': 'snowflake'},
Expand Down Expand Up @@ -150,22 +150,31 @@ def mock_tableau_rest_api():
UserDetailsMock = namedtuple('UserDetailsMock', ['id', 'fullname', 'name'])

workbook_details = {
'customers-workbook-luid': WorkbookDetailsMock(id='aaa', name='Customers workbook'),
'company-kpis-workbook-luid': WorkbookDetailsMock(id='bbb', name='Company KPIs workbook'),
'customers-workbook-luid': WorkbookDetailsMock(id='customers-workbook-luid', name='Customers workbook',
owner_id='user-id'),
'company-kpis-workbook-luid': WorkbookDetailsMock(id='company-kpis-workbook-luid', name='Company KPIs workbook',
owner_id='user-id'),
'orders-workbook-luid': WorkbookDetailsMock(
id='ccc', name='Orders workbook', tags=['certified']
id='orders-workbook-luid', name='Orders workbook', tags=['certified'], owner_id='user-id'
),
}
user_details = {
'user-id': UserDetailsMock('user-id', 'John Doe', '[email protected]')
}

def _get_workbook_details(workbook_id):
return workbook_details[workbook_id]

with patch('exposurescrawler.crawlers.tableau.TableauRestClient', autospec=True) as mock:
instance = mock.return_value
instance.retrieve_workbook.side_effect = _get_workbook_details
instance.retrieve_user.return_value = UserDetailsMock(
'user-id', 'John Doe', '[email protected]'
)
instance.retrieve_user.return_value = user_details['user-id']
instance.retrieve_all_users.return_value = [user_details['user-id']]
instance.retrieve_all_workbooks.return_value = [
workbook_details['customers-workbook-luid'],
workbook_details['company-kpis-workbook-luid'],
workbook_details['orders-workbook-luid']
]
yield


Expand All @@ -183,10 +192,10 @@ def test_tableau_crawler(manifest_path):
tableau_crawler(manifest_path, 'jaffle_shop', [], True)

final_manifest = mock.call_args.args[0].data
exposure = final_manifest['exposures']['exposure.jaffle_shop.tableau_orders_workbook_ccc']
exposure = final_manifest['exposures']['exposure.jaffle_shop.tableau_orders_workbook_ord']

assert len(final_manifest['exposures']) == 3
assert exposure['name'] == 'tableau_orders_workbook_ccc'
assert exposure['name'] == 'tableau_orders_workbook_ord'
assert 'Workbook description' in exposure['description']
assert 'https://my-tableau-server.com/path/to/workbook' in exposure['description']
assert exposure['type'] == 'Dashboard'
Expand Down

0 comments on commit 088cfe0

Please sign in to comment.