1
from common import ObjectTagCollection
4
from tempfile import NamedTemporaryFile
6
""" This is meant to test the ObjectTagCollection bits. It should
7
probably be made into a proper unit test. """
9
x = ObjectTagCollection('test-units')
10
y = ObjectTagCollection('test-relids')
12
o = NamedTemporaryFile(delete=False)
13
o2 = NamedTemporaryFile(delete=False)
14
o3 = NamedTemporaryFile(delete=True)
15
o.write('some content')
18
x.tag_object(o.name, 'box-9')
19
x.tag_object(o.name, 'nrpe-1')
20
y.tag_object(o.name, 'monitors:2')
21
x.tag_object(o2.name, 'box-10')
22
x.tag_object(o2.name, 'nrpe-2')
23
y.tag_object(o2.name, 'monitors:2')
24
x.tag_object(o3.name, 'other-0')
25
y.tag_object(o3.name, 'monitors:3')
26
x.untag_object(o.name, 'box-9')
29
if not os.path.exists(o.name):
30
raise RuntimeError(o.name)
35
if os.path.exists(o.name):
36
raise RuntimeError(o.name)
38
if not os.path.exists(o2.name):
39
raise RuntimeError(o2.name)
41
y.kill_tag('monitors:2')
42
y.cleanup_untagged(['monitors:1','monitors:3'])
44
if os.path.exists(o.name):
45
raise RuntimeError(o2.name)
47
if os.path.exists(o2.name):
48
raise RuntimeError(o2.name)