13980.2.1
by Jeroen Vermeulen
Lint. Lots of lint. |
1 |
# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
|
8687.15.18
by Karl Fogel
Add the copyright header block to files under lib/canonical/. |
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
4417.4.16
by Tom Haddon
Using sqlvalues, commenting on untested parts, and cleaning up |
3 |
|
4 |
"""Test scriptmonitor.py."""
|
|
5 |
||
4417.4.22
by Tom Haddon
Clean up code after comments from Andrew Bennets |
6 |
__metaclass__ = type |
7 |
||
13677.3.2
by Steve Kowalik
Remove unneeded unittest imports. |
8 |
from unittest import TestCase |
4417.4.12
by Tom Haddon
Basic tests (not working) for script monitoring |
9 |
|
14606.3.1
by William Grant
Merge canonical.database into lp.services.database. |
10 |
from lp.scripts.scriptmonitor import check_script |
11 |
from lp.services.database.sqlbase import connect |
|
14565.2.15
by Curtis Hovey
Moved canonical.launchpad.scripts __init__ to lp.services.scripts. |
12 |
from lp.services.scripts import logger |
14604.1.1
by Curtis Hovey
Separate test-authoring classes from test-running classes. |
13 |
from lp.testing.layers import DatabaseLayer |
4417.4.12
by Tom Haddon
Basic tests (not working) for script monitoring |
14 |
|
15 |
||
13677.3.2
by Steve Kowalik
Remove unneeded unittest imports. |
16 |
class CheckScriptTestCase(TestCase): |
4417.4.12
by Tom Haddon
Basic tests (not working) for script monitoring |
17 |
"""Test script activity."""
|
4417.4.15
by Tom Haddon
Working tests |
18 |
layer = DatabaseLayer |
19 |
||
20 |
def setUp(self): |
|
5204.5.4
by Barry Warsaw
Make LaunchpadScript a new-style class, and adjust a super() call accordingly. |
21 |
# We need some fake options so that this test doesn't try to parse
|
22 |
# sys.args. We don't care about the log messages, so just throw them
|
|
23 |
# away.
|
|
24 |
class FakeOptions: |
|
5204.5.5
by Barry Warsaw
Back out the changing to logger(). James called me on this, and he's right. |
25 |
log_file = '/dev/null' |
11300.2.46
by Stuart Bishop
Fix test_scriptmonitor |
26 |
loglevel = 1000 |
5204.5.5
by Barry Warsaw
Back out the changing to logger(). James called me on this, and he's right. |
27 |
verbose = False |
13879.1.5
by William Grant
CheckScriptTestCase too. |
28 |
self.con = connect() |
5204.5.4
by Barry Warsaw
Make LaunchpadScript a new-style class, and adjust a super() call accordingly. |
29 |
self.log = logger(FakeOptions()) |
4417.4.15
by Tom Haddon
Working tests |
30 |
|
31 |
def tearDown(self): |
|
32 |
self.con.close() |
|
4417.4.12
by Tom Haddon
Basic tests (not working) for script monitoring |
33 |
|
34 |
def test_scriptfound(self): |
|
35 |
self.assertEqual( |
|
5204.5.4
by Barry Warsaw
Make LaunchpadScript a new-style class, and adjust a super() call accordingly. |
36 |
check_script(self.con, self.log, 'localhost', |
37 |
'script-monitor-test', |
|
38 |
'2007-05-23 00:30:00', '2007-05-23 01:30:00'), None) |
|
4417.4.12
by Tom Haddon
Basic tests (not working) for script monitoring |
39 |
|
40 |
def test_scriptnotfound_timing(self): |
|
4417.4.18
by Tom Haddon
Merged RF and added Nagios script monitoring check |
41 |
output = ("The script 'script-monitor-test' didn't run on " |
4417.4.15
by Tom Haddon
Working tests |
42 |
"'localhost' between 2007-05-23 01:30:00 and "
|
43 |
"2007-05-23 02:30:00 (last seen 2007-05-23 01:00:00)") |
|
44 |
self.assertEqual( |
|
5204.5.4
by Barry Warsaw
Make LaunchpadScript a new-style class, and adjust a super() call accordingly. |
45 |
check_script(self.con, self.log, 'localhost', |
46 |
'script-monitor-test', |
|
47 |
'2007-05-23 01:30:00', '2007-05-23 02:30:00'), |
|
48 |
output) |
|
4417.4.12
by Tom Haddon
Basic tests (not working) for script monitoring |
49 |
|
50 |
def test_scriptnotfound_hostname(self): |
|
4417.4.18
by Tom Haddon
Merged RF and added Nagios script monitoring check |
51 |
output = ("The script 'script-monitor-test' didn't run on " |
4417.4.15
by Tom Haddon
Working tests |
52 |
"'notlocalhost' between 2007-05-23 00:30:00 and "
|
53 |
"2007-05-23 01:30:00") |
|
54 |
self.assertEqual( |
|
5204.5.4
by Barry Warsaw
Make LaunchpadScript a new-style class, and adjust a super() call accordingly. |
55 |
check_script(self.con, self.log, 'notlocalhost', |
56 |
'script-monitor-test', |
|
57 |
'2007-05-23 00:30:00', '2007-05-23 01:30:00'), |
|
58 |
output) |