diff --git a/contributing.md b/contributing.md index 4adebc091..4c7cdef00 100644 --- a/contributing.md +++ b/contributing.md @@ -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 diff --git a/samples/explore_webhooks.py b/samples/explore_webhooks.py index 052e9a0d6..ab94f7195 100644 --- a/samples/explore_webhooks.py +++ b/samples/explore_webhooks.py @@ -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: @@ -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() @@ -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__': diff --git a/tableauserverclient/server/endpoint/webhooks_endpoint.py b/tableauserverclient/server/endpoint/webhooks_endpoint.py index b6ad4b751..4e69974d1 100644 --- a/tableauserverclient/server/endpoint/webhooks_endpoint.py +++ b/tableauserverclient/server/endpoint/webhooks_endpoint.py @@ -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 diff --git a/test/test_webhook.py b/test/test_webhook.py index 5e124a6c7..819de18ae 100644 --- a/test/test_webhook.py +++ b/test/test_webhook.py @@ -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) @@ -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)