Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ somewhere.
> pip install versioneer
> python setup.py build
> python setup.py test
>
>

### before committing
Our CI runs include a python lint run, so you should run this locally and fix complaints before committing as this will fail your checkin
> pycodestyle tableauserverclient test samples
9 changes: 5 additions & 4 deletions samples/explore_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ def main():
parser.add_argument('--site', '-S', default=None)
parser.add_argument('-p', default=None, help='password')
parser.add_argument('--create', '-c', help='create a webhook')
parser.add_argument('--delete', '-d', help='delete a webhook', action='store_true')
parser.add_argument('--logging-level', '-l', choices=['debug', 'info', 'error'], default='error',
help='desired logging level (set to error by default)')

args = parser.parse_args()


if args.p is None:
password = getpass.getpass("Password: ")
else:
Expand All @@ -52,7 +51,7 @@ def main():

with server.auth.sign_in(tableau_auth):

# Publish webhook if publish flag is set (-publish, -p)
# Create webhook if create flag is set (-create, -c)
if args.create:

new_webhook = TSC.WebhookItem()
Expand All @@ -74,7 +73,9 @@ def main():
# sample_webhook.delete()
print("+++"+sample_webhook.name)


if (args.delete):
print("Deleting webhook " + sample_webhook.name)
server.webhooks.delete(sample_webhook.id)


if __name__ == '__main__':
Expand Down
1 change: 1 addition & 0 deletions tableauserverclient/server/endpoint/webhooks_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ def test(self, webhook_id):
url = "{0}/{1}/test".format(self.baseurl, webhook_id)
testOutcome = self.get_request(url)
logger.info('Testing webhook (ID: {0} returned {1})'.format(webhook_id, testOutcome))
return testOutcome
16 changes: 8 additions & 8 deletions test/test_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ def test_create(self):
response_xml = f.read().decode('utf-8')
with requests_mock.mock() as m:
m.post(self.baseurl, text=response_xml)
new_webhook = TSC.WebhookItem()
new_webhook.name = "Test Webhook"
new_webhook.url = "https://ifttt.com/maker-url"
new_webhook.event = "datasource-created"
new_webhook.owner_id =
webhook_model = TSC.WebhookItem()
webhook_model.name = "Test Webhook"
webhook_model.url = "https://ifttt.com/maker-url"
webhook_model.event = "datasource-created"

new_webhook = self.server.webhooks.create(new_webhook)
new_webhook = self.server.webhooks.create(webhook_model)

self.assertNotEqual(new_webhook.id, None)

Expand All @@ -78,6 +77,7 @@ def test_request_factory(self):
webhook_item = WebhookItem()
webhook_item._set_values("webhook-id", "webhook-name", "url", "api-event-name",
None)
webhook_request_actual = '{}\r\n'.format(RequestFactory.Webhook.create_req(webhook_item).decode('utf-8'))
webhook_request_actual = '{}\n'.format(RequestFactory.Webhook.create_req(webhook_item).decode('utf-8'))
self.maxDiff = None
self.assertEqual(webhook_request_expected, webhook_request_actual)
# windows does /r/n for linebreaks, remove the extra char if it is there
self.assertEqual(webhook_request_expected.replace('\r', ''), webhook_request_actual)