mirror of
https://github.com/status-im/cabot.git
synced 2025-02-24 10:28:06 +00:00
Should be able to match unicode
This commit is contained in:
parent
45300e599f
commit
2fa5abd2c2
@ -478,19 +478,19 @@ class HttpStatusCheck(StatusCheck):
|
||||
auth=auth
|
||||
)
|
||||
except requests.RequestException, e:
|
||||
result.error = 'Request error occurred: %s' % (e,)
|
||||
result.error = u'Request error occurred: %s' % (e,)
|
||||
result.succeeded = False
|
||||
except Exception, e:
|
||||
result.error = 'Error in performing check: %s' % (e,)
|
||||
result.error = u'Error in performing check: %s' % (e,)
|
||||
result.succeeded = False
|
||||
else:
|
||||
if self.status_code and resp.status_code != int(self.status_code):
|
||||
result.error = 'Wrong code: got %s (expected %s)' % (resp.status_code, int(self.status_code))
|
||||
result.error = u'Wrong code: got %s (expected %s)' % (resp.status_code, int(self.status_code))
|
||||
result.succeeded = False
|
||||
result.raw_data = resp.content
|
||||
elif self.text_match:
|
||||
if not re.search(self.text_match, resp.content):
|
||||
result.error = 'Failed to find match regex [%s] in response body' % self.text_match
|
||||
result.error = u'Failed to find match regex [%s] in response body' % self.text_match
|
||||
result.raw_data = resp.content
|
||||
result.succeeded = False
|
||||
else:
|
||||
|
@ -1,3 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import requests
|
||||
from cabotapp.alert import _send_hipchat_alert
|
||||
from django.utils import timezone
|
||||
@ -166,7 +168,13 @@ class TestCheckRun(LocalTestCase):
|
||||
self.assertEqual(len(checkresults), 1)
|
||||
self.assertTrue(self.http_check.last_result().succeeded)
|
||||
self.assertEqual(self.http_check.calculated_status, Service.CALCULATED_PASSING_STATUS)
|
||||
self.http_check.text_match = 'blah blah'
|
||||
self.http_check.text_match = u'blah blah'
|
||||
self.http_check.save()
|
||||
self.http_check.run()
|
||||
self.assertFalse(self.http_check.last_result().succeeded)
|
||||
self.assertEqual(self.http_check.calculated_status, Service.CALCULATED_FAILING_STATUS)
|
||||
# Unicode
|
||||
self.http_check.text_match = u'как закалялась сталь'
|
||||
self.http_check.save()
|
||||
self.http_check.run()
|
||||
self.assertFalse(self.http_check.last_result().succeeded)
|
||||
|
Loading…
x
Reference in New Issue
Block a user