def get(self): webhooks = MobileClient.query(MobileClient.client_type == ClientType.WEBHOOK).fetch() failures = [] for client in webhooks: response = TBANSHelper.ping_webhook(client) if not response.code == 200: failures.append(client.key) count = len(failures) if failures: ndb.delete_multi(failures) logging.info("Deleted {} broken webhooks".format(count)) template_values = {'count': count} path = os.path.join(os.path.dirname(__file__), '../../templates/admin/webhooks_clear_do.html') self.response.out.write(template.render(path, template_values))
def get(self): webhooks = MobileClient.query( MobileClient.client_type == ClientType.WEBHOOK).fetch() failures = [] for client in webhooks: response = TBANSHelper.ping_webhook(client) if not response.code == 200: failures.append(client.key) count = len(failures) if failures: ndb.delete_multi(failures) logging.info("Deleted {} broken webhooks".format(count)) template_values = {'count': count} path = os.path.join(os.path.dirname(__file__), '../../templates/admin/webhooks_clear_do.html') self.response.out.write(template.render(path, template_values))
def test_ping_webhook(self): TBANSHelper._create_service = self._create_mock_service client = MobileClient(client_type=ClientType.WEBHOOK) TBANSHelper.ping_webhook(client)