-
Notifications
You must be signed in to change notification settings - Fork 446
Add workbook to tasks #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
47f6666
add workbook id to tasks and add tests
8f94e29
add workbook id to __repr__
8aec69b
remove unused imports
9ad2544
add target class to abstract references to other objects
30c228c
forgot a new line
aa80e6d
aaaand another new line
4e107ad
add test for schedule id, refactor target
b8757f1
remove #
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| """Target class meant to abstract mappings to other objects""" | ||
|
|
||
|
|
||
| class Target(): | ||
| def __init__(self, id_, target_type): | ||
| self.id = id_ | ||
| self.type = target_type | ||
|
|
||
| def __repr__(self): | ||
| return "<Target#{id}, {type}>".format(**self.__dict__) |
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?xml version='1.0' encoding='UTF-8'?> | ||
| <tsResponse | ||
| xmlns="http://tableau.com/api" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api http://tableau.com/api/ts-api-2.6.xsd"> | ||
| <tasks> | ||
| <task> | ||
| <extractRefresh id="f84901ac-72ad-4f9b-a87e-7a3500402ad6" priority="50" consecutiveFailedCount="0" type="REFRESH_EXTRACT"> | ||
| <schedule id="b60b4efd-a6f7-4599-beb3-cb677e7abac1" name="Refresh daily [23:00 - 01:00, Pacific US]" state="Active" priority="50" createdAt="2016-02-11T01:42:55Z" updatedAt="2017-07-12T06:00:06Z" type="Extract" frequency="Daily" nextRunAt="2017-07-13T06:00:00Z" /> | ||
| </extractRefresh> | ||
| </task> | ||
| <task> | ||
| <extractRefresh id="6e8255f1-142b-4e17-bd9a-9fe6736812a1" priority="50" consecutiveFailedCount="0" type="REFRESH_EXTRACT"> | ||
| <schedule id="82974721-6831-4c78-875c-b7c2d5237bc2" name="Refresh daily [15:00 - 17:00, Pacific US]" state="Active" priority="50" createdAt="2016-02-11T01:39:39Z" updatedAt="2017-07-12T22:00:05Z" type="Extract" frequency="Daily" nextRunAt="2017-07-13T22:00:00Z" /> | ||
| </extractRefresh> | ||
| </task> | ||
| <task> | ||
| <extractRefresh id="90cbc49a-b668-4355-9321-46f7fefd4197" priority="50" consecutiveFailedCount="0" type="REFRESH_EXTRACT"> | ||
| <schedule id="c39a5a41-ab5b-4661-90f6-78384916748c" name="Refresh daily [00:00 - 02:00, Pacific US]" state="Active" priority="50" createdAt="2016-02-11T01:33:51Z" updatedAt="2017-07-12T07:00:08Z" type="Extract" frequency="Daily" nextRunAt="2017-07-13T07:00:00Z" /> | ||
| </extractRefresh> | ||
| </task> | ||
| </tasks> | ||
| </tsResponse> |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <?xml version='1.0' encoding='UTF-8'?> | ||
| <tsResponse | ||
| xmlns="http://tableau.com/api" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api http://tableau.com/api/ts-api-2.6.xsd"> | ||
| <tasks> | ||
| <task> | ||
| <extractRefresh id="f84901ac-72ad-4f9b-a87e-7a3500402ad6" priority="50" consecutiveFailedCount="0" type="REFRESH_EXTRACT"> | ||
| <schedule id="b60b4efd-a6f7-4599-beb3-cb677e7abac1" name="Refresh daily [23:00 - 01:00, Pacific US]" state="Active" priority="50" createdAt="2016-02-11T01:42:55Z" updatedAt="2017-07-12T06:00:06Z" type="Extract" frequency="Daily" nextRunAt="2017-07-13T06:00:00Z" /> | ||
| <datasource id="c7a9327e-1cda-4504-b026-ddb43b976d1d" /> | ||
| </extractRefresh> | ||
| </task> | ||
| </tasks> | ||
| </tsResponse> |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <?xml version='1.0' encoding='UTF-8'?> | ||
| <tsResponse | ||
| xmlns="http://tableau.com/api" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api http://tableau.com/api/ts-api-2.6.xsd"> | ||
| <tasks> | ||
| <task> | ||
| <extractRefresh id="f84901ac-72ad-4f9b-a87e-7a3500402ad6" priority="50" consecutiveFailedCount="0" type="REFRESH_EXTRACT"> | ||
| <schedule id="b60b4efd-a6f7-4599-beb3-cb677e7abac1" name="Refresh daily [23:00 - 01:00, Pacific US]" state="Active" priority="50" createdAt="2016-02-11T01:42:55Z" updatedAt="2017-07-12T06:00:06Z" type="Extract" frequency="Daily" nextRunAt="2017-07-13T06:00:00Z" /> | ||
| <workbook id="c7a9327e-1cda-4504-b026-ddb43b976d1d" /> | ||
| </extractRefresh> | ||
| </task> | ||
| </tasks> | ||
| </tsResponse> |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?xml version='1.0' encoding='UTF-8'?> | ||
| <tsResponse | ||
| xmlns="http://tableau.com/api" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api http://tableau.com/api/ts-api-2.6.xsd"> | ||
| <tasks> | ||
| <task> | ||
| <extractRefresh id="f84901ac-72ad-4f9b-a87e-7a3500402ad6" priority="50" consecutiveFailedCount="0" type="REFRESH_EXTRACT"> | ||
| <schedule id="b60b4efd-a6f7-4599-beb3-cb677e7abac1" name="Refresh daily [23:00 - 01:00, Pacific US]" state="Active" priority="50" createdAt="2016-02-11T01:42:55Z" updatedAt="2017-07-12T06:00:06Z" type="Extract" frequency="Daily" nextRunAt="2017-07-13T06:00:00Z" /> | ||
| <workbook id="c7a9327e-1cda-4504-b026-ddb43b976d1d" /> | ||
| </extractRefresh> | ||
| </task> | ||
| <task> | ||
| <extractRefresh id="6e8255f1-142b-4e17-bd9a-9fe6736812a1" priority="50" consecutiveFailedCount="0" type="REFRESH_EXTRACT"> | ||
| <schedule id="82974721-6831-4c78-875c-b7c2d5237bc2" name="Refresh daily [15:00 - 17:00, Pacific US]" state="Active" priority="50" createdAt="2016-02-11T01:39:39Z" updatedAt="2017-07-12T22:00:05Z" type="Extract" frequency="Daily" nextRunAt="2017-07-13T22:00:00Z" /> | ||
| <datasource id="61334430-fb0c-43af-a5a3-8db3323644b6" /> | ||
| </extractRefresh> | ||
| </task> | ||
| <task> | ||
| <extractRefresh id="90cbc49a-b668-4355-9321-46f7fefd4197" priority="50" consecutiveFailedCount="0" type="REFRESH_EXTRACT"> | ||
| <schedule id="c39a5a41-ab5b-4661-90f6-78384916748c" name="Refresh daily [00:00 - 02:00, Pacific US]" state="Active" priority="50" createdAt="2016-02-11T01:33:51Z" updatedAt="2017-07-12T07:00:08Z" type="Extract" frequency="Daily" nextRunAt="2017-07-13T07:00:00Z" /> | ||
| <workbook id="952663f4-1bb4-4fed-91f8-5967f48c533a" /> | ||
| </extractRefresh> | ||
| </task> | ||
| </tasks> | ||
| </tsResponse> |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import unittest | ||
| import os | ||
| import requests_mock | ||
| import tableauserverclient as TSC | ||
|
|
||
| TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") | ||
|
|
||
| GET_XML_NO_WORKBOOK = os.path.join(TEST_ASSET_DIR, "tasks_no_workbook_or_datasource.xml") | ||
| GET_XML_WITH_WORKBOOK = os.path.join(TEST_ASSET_DIR, "tasks_with_workbook.xml") | ||
| GET_XML_WITH_DATASOURCE = os.path.join(TEST_ASSET_DIR, "tasks_with_datasource.xml") | ||
| GET_XML_WITH_WORKBOOK_AND_DATASOURCE = os.path.join(TEST_ASSET_DIR, "tasks_with_workbook_and_datasource.xml") | ||
|
|
||
|
|
||
| class TaskTests(unittest.TestCase): | ||
| def setUp(self): | ||
| self.server = TSC.Server("http://test") | ||
| self.server.version = '2.6' | ||
|
|
||
| # Fake Signin | ||
| self.server._site_id = "dad65087-b08b-4603-af4e-2887b8aafc67" | ||
| self.server._auth_token = "j80k54ll2lfMZ0tv97mlPvvSCRyD0DOM" | ||
|
|
||
| self.baseurl = self.server.tasks.baseurl | ||
|
|
||
| def test_get_tasks_with_no_workbook(self): | ||
| with open(GET_XML_NO_WORKBOOK, "rb") as f: | ||
| response_xml = f.read().decode("utf-8") | ||
| with requests_mock.mock() as m: | ||
| m.get(self.baseurl, text=response_xml) | ||
| all_tasks, pagination_item = self.server.tasks.get() | ||
|
|
||
| task = all_tasks[0] | ||
| self.assertEqual(None, task.target) | ||
|
|
||
| def test_get_tasks_with_workbook(self): | ||
| with open(GET_XML_WITH_WORKBOOK, "rb") as f: | ||
| response_xml = f.read().decode("utf-8") | ||
| with requests_mock.mock() as m: | ||
| m.get(self.baseurl, text=response_xml) | ||
| all_tasks, pagination_item = self.server.tasks.get() | ||
|
|
||
| task = all_tasks[0] | ||
| self.assertEqual('c7a9327e-1cda-4504-b026-ddb43b976d1d', task.target.id) | ||
| self.assertEqual('workbook', task.target.type) | ||
|
|
||
| def test_get_tasks_with_datasource(self): | ||
| with open(GET_XML_WITH_DATASOURCE, "rb") as f: | ||
| response_xml = f.read().decode("utf-8") | ||
| with requests_mock.mock() as m: | ||
| m.get(self.baseurl, text=response_xml) | ||
| all_tasks, pagination_item = self.server.tasks.get() | ||
|
|
||
| task = all_tasks[0] | ||
| self.assertEqual('c7a9327e-1cda-4504-b026-ddb43b976d1d', task.target.id) | ||
| self.assertEqual('datasource', task.target.type) | ||
|
|
||
| def test_get_tasks_with_workbook_and_datasource(self): | ||
| with open(GET_XML_WITH_WORKBOOK_AND_DATASOURCE, "rb") as f: | ||
| response_xml = f.read().decode("utf-8") | ||
| with requests_mock.mock() as m: | ||
| m.get(self.baseurl, text=response_xml) | ||
| all_tasks, pagination_item = self.server.tasks.get() | ||
|
|
||
| self.assertEqual('workbook', all_tasks[0].target.type) | ||
| self.assertEqual('datasource', all_tasks[1].target.type) | ||
| self.assertEqual('workbook', all_tasks[2].target.type) | ||
|
|
||
| def test_get_task_with_schedule(self): | ||
| with open(GET_XML_WITH_WORKBOOK, "rb") as f: | ||
| response_xml = f.read().decode("utf-8") | ||
| with requests_mock.mock() as m: | ||
| m.get(self.baseurl, text=response_xml) | ||
| all_tasks, pagination_item = self.server.tasks.get() | ||
|
|
||
| task = all_tasks[0] | ||
| self.assertEqual('c7a9327e-1cda-4504-b026-ddb43b976d1d', task.target.id) | ||
| self.assertEqual('workbook', task.target.type) | ||
| self.assertEqual('b60b4efd-a6f7-4599-beb3-cb677e7abac1', task.schedule_id) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is technically never possible, right? (though a test for it is fine -- we may do this someday)