summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-06-23 12:30:56 -0400
committerMichael DeHaan <mdehaan@redhat.com>2008-06-23 12:30:56 -0400
commit5aeaa5a411c2e5b8f297ba1eed02aa2663ff7225 (patch)
tree3d93438c48edb9b3fdb27dafb01cd38b3f754321 /test
parent76996c8ac3016389fdafb47e7791f2c636e2a4ed (diff)
parent30a2391e1078bca14c83ad3b433a46f6929b29f4 (diff)
downloadfunc-5aeaa5a411c2e5b8f297ba1eed02aa2663ff7225.tar.gz
func-5aeaa5a411c2e5b8f297ba1eed02aa2663ff7225.tar.xz
func-5aeaa5a411c2e5b8f297ba1eed02aa2663ff7225.zip
Merge branch 'makkalot_extreme'
Diffstat (limited to 'test')
-rw-r--r--test/unittest/test_client.py11
-rw-r--r--test/unittest/test_func_arg.py151
2 files changed, 161 insertions, 1 deletions
diff --git a/test/unittest/test_client.py b/test/unittest/test_client.py
index 578dd90..1a3f7cd 100644
--- a/test/unittest/test_client.py
+++ b/test/unittest/test_client.py
@@ -13,7 +13,7 @@ import socket
class BaseTest:
# assume we are talking to localhost
-# th = socket.gethostname()
+ # th = socket.gethostname()
th = socket.getfqdn()
nforks=1
async=False
@@ -46,6 +46,12 @@ class BaseTest:
result = mod.list_methods()
self.assert_on_fault(result)
+ def test_module_get_method_args(self):
+ mod = getattr(self.overlord,self.module)
+ arg_result=mod.get_method_args()
+ print arg_result
+ self.assert_on_fault(arg_result)
+
def test_module_inventory(self):
mod = getattr(self.overlord, self.module)
result = mod.list_methods()
@@ -70,6 +76,7 @@ class BaseTest:
test_module_description.intro = True
test_module_list_methods.intro = True
test_module_inventory.intro = True
+ test_module_get_method_args.intro = True
class TestTest(BaseTest):
module = "test"
@@ -381,6 +388,8 @@ class TestSystem(BaseTest):
def test_module_description(self):
pass
+ def test_module_get_method_args(self):
+ pass
#import time
diff --git a/test/unittest/test_func_arg.py b/test/unittest/test_func_arg.py
new file mode 100644
index 0000000..f22861a
--- /dev/null
+++ b/test/unittest/test_func_arg.py
@@ -0,0 +1,151 @@
+##
+## Copyright 2007, Red Hat, Inc
+## see AUTHORS
+##
+## This software may be freely redistributed under the terms of the GNU
+## general public license.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+##
+
+#tester module for ArgCompatibility
+from func.minion.func_arg import ArgCompatibility
+
+class TestArgCompatibility:
+
+ def setUp(self):
+ #create the simple object
+ self.ac = ArgCompatibility(self.dummy_arg_getter())
+
+ def test_arg_compatibility(self):
+ """
+ Testing the method argument compatiblity
+ """
+ result = self.ac.validate_all()
+ assert result == True
+
+ self.ac = ArgCompatibility(self.dummy_no_getter())
+ result = self.ac.validate_all()
+ assert result == True
+
+ self.ac = ArgCompatibility(self.dummy_empty_args())
+ result = self.ac.validate_all()
+ assert result == True
+
+ def test_is_all_arguments_registered(self):
+ #create the dummy class
+ tc = FooClass()
+ arguments = tc.register_method()
+ assert self.ac.is_all_arguments_registered(tc,'foomethod',arguments['foomethod']['args'])==True
+ print arguments
+ assert self.ac.validate_all()==True
+
+ def dummy_no_getter(self):
+ return {}
+
+ def dummy_empty_args(self):
+ return{
+ 'myfunc':{
+ 'args':{},
+ 'description':'Cool methods here'
+ }
+ }
+
+ def dummy_arg_getter(self):
+ """
+ A simple method to test the stuff we have written for
+ arg compatiblity. I just return a dict with proper stuff
+ Should more an more tests here to see if didnt miss something
+ """
+ return {
+ 'hifunc':{
+
+ 'args':{
+ 'app':{
+ 'type':'int',
+ 'range':[0,100],
+ 'optional':False,
+ 'default' : 12
+ },
+
+ 'platform':{
+ 'type':'string',
+ 'options':["fedora","redhat","ubuntu"],
+ 'description':"Hey im a fedora fan",
+ 'default':'fedora8',
+ },
+
+ 'platform2':{
+ 'type':'string',
+ 'min_length':4,
+ 'max_length':33,
+ 'description':"Hey im a fedora fan",
+ 'default':'fedora8',
+ },
+
+
+ 'is_independent':{
+ 'type':'boolean',
+ 'default' :False,
+ 'description':'Are you independent ?',
+ 'optional':False
+ },
+
+ 'some_string':{
+ 'type':'string',
+ 'validator': "^[a-zA-Z]$",
+ 'description':'String to be validated',
+ 'default':'makkalot',
+ 'optional':False}, # validator is a re string for those whoo need better validation,so when we have options there is no need to use validator and reverse is True
+ #to define also a float we dont need it actually but maybe useful for the UI stuff.
+ 'some_float':{
+ 'type':'float',
+ 'description':'The float point value',
+ 'default':33.44,
+ 'optional':False
+ },
+
+ 'some_iterable':{
+ 'type':'list',
+ 'description':'The value and description for *arg',
+ 'optional':True, #that is where it makes sense
+ 'validator':'^[0-9]+$',#maybe useful to say it is to be a number for example
+ },
+
+ 'some_hash':{
+ 'type':'hash',
+ 'description':"Dummy desc here",
+ 'optional':True, #of course it is,
+ 'validator':"^[a-z]*$",#only for values not keys
+
+ }
+ },
+ 'description':"The dummy method description",
+ }
+ }
+
+
+class FooClass(object):
+ """
+ Sample class for testing the is_all_arguments_registered
+ method functionality ...
+ """
+
+ def foomethod(self,arg1,arg5,arg4,*arg,**kw):
+ pass
+
+ def register_method(self):
+ return{
+ 'foomethod':{
+ 'args':{
+ 'arg1':{},
+ 'arg4':{},
+ 'arg5':{},
+ 'arg':{},
+ 'kw':{},
+ }
+ }
+ }
+