forked from mattwesthoff/splunk-sla-lookup
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sla_lookup_tests.py
60 lines (45 loc) · 2.25 KB
/
sla_lookup_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import unittest
from sla_lookup import xrow_matches, is_staging, lookup
from datetime import datetime
class xRowMatchesTests(unittest.TestCase):
def test_allwild(self):
self.assertTrue(xrow_matches("javelin.staging.zsservices.com/client/0001a", ["*", "*", "*"]))
def test_correctenv(self):
self.assertTrue(xrow_matches("javelin.staging.zsservices.com/client/0001a", ["Stg", "*", "*"]))
def test_correctgroup(self):
self.assertTrue(xrow_matches("javelin.staging.zsservices.com/client/0001a", ["*", "*", "client"]))
def test_correctapp(self):
self.assertTrue(xrow_matches("javelin.staging.zsservices.com/client/0001a", ["*", "0001", "*"]))
def test_allspecified(self):
self.assertTrue(xrow_matches("javelin.staging.zsservices.com/client/0001a", ["Stg", "0001a", "client"]))
class isStagingTests(unittest.TestCase):
def test_staging(self):
self.assertTrue(is_staging("staging"))
def test_prod(self):
self.assertFalse(is_staging("javelin.zsservices"))
def test_blank(self):
self.assertFalse(is_staging(""))
class lookupTests(unittest.TestCase):
def setUp(self):
self.event_time = 1350421479 #Tue Oct 16 2012 16:04:39 GMT-5
self.test_name = "javelin.zsservices.com/Amgen/0002a/tacos"
def test_windowmatches(self):
windows = [[("*","*","*"), datetime(2012,10,16,14,0,0), datetime(2012,10,16,17,0,0)]]
self.assertTrue(lookup(self.test_name, self.event_time, windows))
def test_shouldnotmatchtestname(self):
windows = [[("Stg","0012","*"), datetime(2012,10,16,14,0,0), datetime(2012,10,16,17,0,0)]]
test_name = "javelin.zsservices.com/Amgen/0002a/tacos"
self.assertFalse(lookup(self.test_name, self.event_time, windows))
def test_shouldnotmatchdates(self):
windows = [[("*","*","*"), datetime(2012,10,14,14,0,0), datetime(2012,10,14,17,0,0)]]
test_name = "javelin.zsservices.com/Amgen/0002a/tacos"
self.assertFalse(lookup(self.test_name, self.event_time, windows))
def test_matchesmanywindows(self):
windows = [
[("*","*","*"), datetime(2012,10,16,14,0,0), datetime(2012,10,16,17,0,0)],
[("Prod","*","Amgen"), datetime(2012,10,16,14,0,0), datetime(2012,10,16,17,0,0)]
]
test_name = "javelin.zsservices.com/Amgen/0002a/tacos"
self.assertTrue(lookup(self.test_name, self.event_time, windows))
if __name__ == '__main__':
unittest.main()