mirror of
https://github.com/mtan93/cachet-url-monitor.git
synced 2026-03-08 05:31:58 +00:00
Adding REGEX to sample configuration and updating the unit tests.
This commit is contained in:
@@ -74,26 +74,26 @@ class HttpStatusTest(unittest.TestCase):
|
||||
|
||||
class RegexTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.expectation = Regex({'type': 'REGEX', 'regex': '.*(found stuff).*'})
|
||||
self.expectation = Regex({'type': 'REGEX', 'regex': '.*(find stuff).*'})
|
||||
|
||||
def test_init(self):
|
||||
assert self.expectation.regex == re.compile('.*(found stuff).*')
|
||||
assert self.expectation.regex == re.compile('.*(find stuff).*')
|
||||
|
||||
def test_get_status_healthy(self):
|
||||
request = mock.Mock()
|
||||
request.text = 'We cound found stuff in this body.'
|
||||
request.text = 'We could find stuff in this body.'
|
||||
|
||||
assert self.expectation.get_status(request) == 1
|
||||
|
||||
def test_get_status_unhealthy(self):
|
||||
request = mock.Mock()
|
||||
request.text = 'We will not find here'
|
||||
request.text = 'We will not find it here'
|
||||
|
||||
assert self.expectation.get_status(request) == 3
|
||||
|
||||
def test_get_message(self):
|
||||
request = mock.Mock()
|
||||
request.text = 'We will not find here'
|
||||
request.text = 'We will not find it here'
|
||||
|
||||
assert self.expectation.get_message(request) == ('Regex did not match '
|
||||
'anything in the body')
|
||||
|
||||
Reference in New Issue
Block a user