mirror of
https://github.com/mtan93/cachet-url-monitor.git
synced 2026-03-08 05:31:58 +00:00
Addressing codacy issues
This commit is contained in:
@@ -294,9 +294,10 @@ class Expectaction(object):
|
|||||||
|
|
||||||
class HttpStatus(Expectaction):
|
class HttpStatus(Expectaction):
|
||||||
def __init__(self, configuration):
|
def __init__(self, configuration):
|
||||||
self.status_range = self.parse_range(configuration['status_range'])
|
self.status_range = HttpStatus.parse_range(configuration['status_range'])
|
||||||
|
|
||||||
def parse_range(self, range_string):
|
@staticmethod
|
||||||
|
def parse_range(range_string):
|
||||||
statuses = range_string.split("-")
|
statuses = range_string.split("-")
|
||||||
if len(statuses) == 1:
|
if len(statuses) == 1:
|
||||||
# When there was no range given, we should treat the first number as a single status check.
|
# When there was no range given, we should treat the first number as a single status check.
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class HttpStatusTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_init_with_invalid_number(self):
|
def test_init_with_invalid_number(self):
|
||||||
"""Invalid values should just fail with a ValueError, as we can't convert it to int."""
|
"""Invalid values should just fail with a ValueError, as we can't convert it to int."""
|
||||||
with pytest.raises(ValueError) as excinfo:
|
with pytest.raises(ValueError):
|
||||||
self.expectation = HttpStatus({'type': 'HTTP_STATUS', 'status_range': "foo"})
|
self.expectation = HttpStatus({'type': 'HTTP_STATUS', 'status_range': "foo"})
|
||||||
|
|
||||||
def test_get_status_healthy(self):
|
def test_get_status_healthy(self):
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import unittest
|
|
||||||
|
|
||||||
from cachet_url_monitor.latency_unit import convert_to_unit
|
from cachet_url_monitor.latency_unit import convert_to_unit
|
||||||
|
|
||||||
|
|
||||||
class ConfigurationTest(unittest.TestCase):
|
def test_convert_to_unit_ms():
|
||||||
def test_convert_to_unit_ms(self):
|
|
||||||
assert convert_to_unit("ms", 1) == 1000
|
assert convert_to_unit("ms", 1) == 1000
|
||||||
|
|
||||||
def test_convert_to_unit_s(self):
|
|
||||||
|
def test_convert_to_unit_s():
|
||||||
assert convert_to_unit("s", 20) == 20
|
assert convert_to_unit("s", 20) == 20
|
||||||
|
|
||||||
def test_convert_to_unit_m(self):
|
|
||||||
|
def test_convert_to_unit_m():
|
||||||
assert convert_to_unit("m", 3) == float(3) / 60
|
assert convert_to_unit("m", 3) == float(3) / 60
|
||||||
|
|
||||||
def test_convert_to_unit_h(self):
|
|
||||||
|
def test_convert_to_unit_h():
|
||||||
assert convert_to_unit("h", 7200) == 2
|
assert convert_to_unit("h", 7200) == 2
|
||||||
|
|||||||
Reference in New Issue
Block a user