-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tableau-exposer-crawler): addressing tests
- Loading branch information
1 parent
2e69704
commit 088cfe0
Showing
1 changed file
with
18 additions
and
9 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 |
---|---|---|
|
@@ -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'}, | ||
|
@@ -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 | ||
|
||
|
||
|
@@ -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' | ||
|