summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAdrian Likins <alikins@grimlock.devel.redhat.com>2008-01-16 14:38:42 -0500
committerAdrian Likins <alikins@grimlock.devel.redhat.com>2008-01-16 14:38:42 -0500
commitb287962c5d7b2d705f6ed64d781ca4f6045c7ca2 (patch)
tree1902d799a54da19e99530b190299c2dc520334d7 /test
parent97681db386965718318b88b7b753fc64b38bb96d (diff)
downloadthird_party-func-b287962c5d7b2d705f6ed64d781ca4f6045c7ca2.tar.gz
third_party-func-b287962c5d7b2d705f6ed64d781ca4f6045c7ca2.tar.xz
third_party-func-b287962c5d7b2d705f6ed64d781ca4f6045c7ca2.zip
a start at some unittest modules.
This expects the "python-nose" package to be installed. To test, run "nosetests" in the unittest subdir
Diffstat (limited to 'test')
-rw-r--r--test/unittest/test_client.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/test/unittest/test_client.py b/test/unittest/test_client.py
new file mode 100644
index 0000000..8a44a97
--- /dev/null
+++ b/test/unittest/test_client.py
@@ -0,0 +1,65 @@
+#!/usr/bin/python
+
+import os
+import unittest
+import xmlrpclib
+
+import func.overlord.client as fc
+
+
+
+class BaseTest:
+ th = "grimlock.devel.redhat.com"
+ def __init__(self):
+ pass
+
+ def setUp(self):
+ self.client = fc.Client(self.th)
+
+
+
+class TestTest(BaseTest):
+ def test_add(self):
+ result = self.client.test.add(1,5)
+ assert result[self.th] == 6
+
+ def test_add_string(self):
+ result = self.client.test.add("foo", "bar")
+ assert result[self.th] == "foobar"
+
+ def tearDown(self):
+ pass
+
+
+class TestCommand(BaseTest):
+ def test_echo(self):
+ result = self.client.command.run("echo -n foo")
+ assert result[self.th][1] == "foo"
+
+ def test_rpm(self):
+ result = self.client.command.run("rpm -q func")
+ assert result[self.th][1].split("-")[0] == "func"
+
+
+
+class TestCopyfile(BaseTest):
+ fn = "/tmp/func_test_file"
+ content = "this is a func test file"
+ def create_a_file(self):
+ f = open(self.fn, "w")
+ f.write(self.content)
+ f.close()
+
+ def test_copyfile(self):
+ "run a test case"
+ self.create_a_file()
+ fb = open(self.fn,"r").read()
+ print fb
+ data = xmlrpclib.Binary(fb)
+ result = self.client.copyfile.copyfile(self.fn, data)
+ assert result[self.th] == 0
+
+
+
+#f = TestBar()
+#f.test_add()