summaryrefslogtreecommitdiffstats
path: root/test/unittest
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-01-23 12:38:46 -0500
committerMichael DeHaan <mdehaan@redhat.com>2008-01-23 12:38:46 -0500
commitce0eaca23fb42f77f67408e509bbe091f4c27e56 (patch)
treef0d331f83654869b619bd34e33a4fe1c884daa8a /test/unittest
parent504041eb26aba41092aa528e1a724fa5554063d7 (diff)
parentbf8fcc5ebd930a241ce56216e7e610d456be6a69 (diff)
downloadthird_party-func-ce0eaca23fb42f77f67408e509bbe091f4c27e56.tar.gz
third_party-func-ce0eaca23fb42f77f67408e509bbe091f4c27e56.tar.xz
third_party-func-ce0eaca23fb42f77f67408e509bbe091f4c27e56.zip
Merge branch 'master' of ssh://git.fedoraproject.org/git/hosted/func
Conflicts: test/unittest/test_client.py
Diffstat (limited to 'test/unittest')
-rw-r--r--test/unittest/test_client.py90
1 files changed, 54 insertions, 36 deletions
diff --git a/test/unittest/test_client.py b/test/unittest/test_client.py
index f4f2029..b7c5e7b 100644
--- a/test/unittest/test_client.py
+++ b/test/unittest/test_client.py
@@ -1,6 +1,7 @@
#!/usr/bin/python
import os
+import socket
import unittest
import xmlrpclib
@@ -10,7 +11,8 @@ import socket
class BaseTest:
- th = "mdehaan.rdu.redhat.com"
+ # assume we are talking to localhost
+ th = socket.gethostname()
def __init__(self):
pass
@@ -20,16 +22,20 @@ class BaseTest:
def test_module_version(self):
mod = getattr(self.client, self.module)
result = mod.module_version()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
def test_module_api_version(self):
mod = getattr(self.client, self.module)
result = mod.module_api_version()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
def test_module_description(self):
mod = getattr(self.client, self.module)
result = mod.module_description()
+ self.assert_on_fault(result)
+
+ # we do this all over the place...
+ def assert_on_fault(self, result):
assert type(result[self.th]) != xmlrpclib.Fault
test_module_version.intro = True
@@ -41,16 +47,14 @@ class TestTest(BaseTest):
module = "test"
def test_add(self):
result = self.client.test.add(1,5)
-
+ self.assert_on_fault(result)
assert result[self.th] == 6
def test_add_string(self):
result = self.client.test.add("foo", "bar")
-
+ self.assert_on_fault(result)
assert result[self.th] == "foobar"
- def tearDown(self):
- pass
class TestCommand(BaseTest):
@@ -58,11 +62,13 @@ class TestCommand(BaseTest):
def test_echo(self):
result = self.client.command.run("echo -n foo")
+ self.assert_on_fault(result)
assert result[self.th][1] == "foo"
def test_rpm(self):
result = self.client.command.run("rpm -q func")
+ self.assert_on_fault(result)
assert result[self.th][1].split("-")[0] == "func"
@@ -82,7 +88,9 @@ class TestCopyfile(BaseTest):
fb = open(self.fn,"r").read()
data = xmlrpclib.Binary(fb)
result = self.client.copyfile.copyfile(self.dest_fn, data)
+ self.assert_on_fault(result)
assert result[self.th] == 0
+
def test_checksum(self):
self.create_a_file()
@@ -90,6 +98,7 @@ class TestCopyfile(BaseTest):
data = xmlrpclib.Binary(fb)
result = self.client.copyfile.copyfile(self.dest_fn, data)
result = self.client.copyfile.checksum(self.dest_fn)
+ self.assert_on_fault(result)
assert result[self.th] == "b36a8040e44c16605d7784cdf1b3d9ed04ea7f55"
@@ -97,19 +106,20 @@ class TestHardware(BaseTest):
module = "hardware"
def test_inventory(self):
result = self.client.hardware.inventory()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
def test_halinfo(self):
result = self.client.hardware.hal_info()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
def test_info(self):
result = self.client.hardware.info()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
+
def test_info_no_devices(self):
result = self.client.hardware.info(False)
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
class TestFileTracker(BaseTest):
fn = "/etc/hosts"
@@ -117,18 +127,19 @@ class TestFileTracker(BaseTest):
def test_track(self):
result = self.client.filetracker.track(self.fn)
assert result[self.th] == 1
+ self.assert_on_fault(result)
def test_inventory(self):
result = self.client.filetracker.track(self.fn)
result = self.client.filetracker.inventory(False)
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
assert result[self.th][0][0] == "/etc/hosts"
assert result[self.th][0][3] == 0
def test_untrack(self):
result = self.client.filetracker.track(self.fn)
result = self.client.filetracker.untrack(self.fn)
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
result_inv = self.client.filetracker.inventory(False)
tracked_files = result_inv[self.th]
for i in tracked_files:
@@ -140,9 +151,7 @@ class TestMount(BaseTest):
module = "mount"
def test_mount_list(self):
result = self.client.mount.list()
- #FIXME: I probably should make the test for xmlrpclib faults a bit
- # more automagic
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
# INSERT some clever way to test mount here
@@ -151,8 +160,8 @@ class TestNetworkTest(BaseTest):
module = "networktest"
def test_ping(self):
result = self.client.networktest.ping(self.th, "-c", "2")
- assert type(result[self.th]) != xmlrpclib.Fault
-
+ self.assert_on_fault(result)
+
def test_ping_bad_arg(self):
result = self.client.networktest.ping(self.th)
# this should give us a FuncException
@@ -160,34 +169,34 @@ class TestNetworkTest(BaseTest):
def test_netstat(self):
result = self.client.networktest.netstat("-n")
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
def test_traceroute(self):
result = self.client.networktest.traceroute(self.th)
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
def test_dig(self):
result = self.client.networktest.dig("redhat.com")
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
def test_isportopen_closed_port(self):
result = self.client.networktest.isportopen(self.th, 34251)
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
def test_isportopen_open_port(self):
result = self.client.networktest.isportopen(self.th, 51234)
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
class TestProcess(BaseTest):
module = "process"
def test_info(self):
result = self.client.process.info()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
def test_mem(self):
result = self.client.process.mem()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
# FIXME: how to test kill/pkill? start a process with
# command and then kill it?
@@ -197,20 +206,20 @@ class TestService(BaseTest):
module = "service"
def test_inventory(self):
result = self.client.service.inventory()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
def test_get_enabled(self):
result = self.client.service.get_enabled()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
def test_get_running(self):
result = self.client.service.get_running()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
def test_get_status(self):
running_data = self.client.service.get_running()[self.th]
result = self.client.service.status(running_data[0][0])
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
assert result[self.th] == 0
#FIXME: whats a good way to test starting/stoping services without
@@ -220,37 +229,46 @@ class TestRpm(BaseTest):
module = "rpms"
def test_inventory(self):
result = self.client.rpms.inventory()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
class TestSmart(BaseTest):
module = "smart"
def test_info(self):
result = self.client.smart.info()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
+class TestSysctl(BaseTest):
+ module = "sysctl"
+ def test_list(self):
+ result = self.client.sysctl.list()
+ self.assert_on_fault(result)
+
+ def test_get(self):
+ result = self.client.sysctl.get("kernel.max_lock_depth")
+ self.assert_on_fault(result)
+
class TestYum(BaseTest):
module = "yumcmd"
def test_check_update(self):
result = self.client.yumcmd.check_update()
- assert type(result[self.th]) != xmlrpclib.Fault
- print result
+ self.assert_on_fault(result)
class TestSystem(BaseTest):
module = "system"
def test_list_methods(self):
result = self.client.system.list_methods()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
def test_listMethods(self):
result = self.client.system.listMethods()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
def test_list_modules(self):
result = self.client.system.list_modules()
- assert type(result[self.th]) != xmlrpclib.Fault
+ self.assert_on_fault(result)
#FIXME: we really should just implement these for the system stuff