summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAdrian Likins <alikins@grimlock.devel.redhat.com>2008-02-12 14:36:27 -0500
committerAdrian Likins <alikins@grimlock.devel.redhat.com>2008-02-12 14:36:27 -0500
commit7e232e4a72a68ddcfa21cc44c705d8b6cc0092a4 (patch)
treed08ea10a77119cbf1c281a9f6b0bd98caa4f35fa /test
parentbca510c2645ff24e5373dc0e7ff978ba7184693d (diff)
downloadthird_party-func-7e232e4a72a68ddcfa21cc44c705d8b6cc0092a4.tar.gz
third_party-func-7e232e4a72a68ddcfa21cc44c705d8b6cc0092a4.tar.xz
third_party-func-7e232e4a72a68ddcfa21cc44c705d8b6cc0092a4.zip
Refactor the minion/server list and group stuff. Still not ideal, but
a touch more OO. Also update unittests/etc. Did some s/servers/minions/ renaming while I was at it as well. Need to go back and finish that up.
Diffstat (limited to 'test')
-rw-r--r--test/unittest/test_groups.py57
1 files changed, 50 insertions, 7 deletions
diff --git a/test/unittest/test_groups.py b/test/unittest/test_groups.py
index 32da15c..95dd795 100644
--- a/test/unittest/test_groups.py
+++ b/test/unittest/test_groups.py
@@ -2,26 +2,69 @@
# unit tests for group functionality in func
+import os
import func.overlord.client as fc
+import ConfigParser
-class GroupBuilder(object):
- def __init__(self):
- pass
+GROUP_TEST="/tmp/func.test.groups"
+
+class GroupFileBuilder(object):
+ def __init__(self, filename=GROUP_TEST):
+ self.filename = filename
+ if os.access(self.filename, os.R_OK):
+ os.unlink(self.filename)
+ self.cp = ConfigParser.SafeConfigParser()
+
+ def create(self, dict):
+ # dict is a dict of section names, whose values
+ # are a list of tuples of key=value
+ # aka foo = {'section1':[(key1, value1), (key2, value2)],
+ # "section2":[(key3, value3)]}
+ for section in dict.keys():
+ self.cp.add_section(section)
+ for (option, value) in dict[section]:
+ self.cp.set(section, option, value)
+
+ fo = open(self.filename, "a+")
+ self.cp.write(fo)
-
+class GroupsBase(object):
+ def __init__(self):
+ self.minions = fc.Minions("*", groups_file=GROUP_TEST)
-class TestGroups(object):
def test_expand_servers(self):
- result = fc.expand_servers("*")
+ result = self.minions.get_urls()
print result
def test_get_groups(self):
- result = fc.get_groups()
+ result = self.minions.group_class.get_groups()
print result
+
+class Groups(GroupsBase):
+ def get_hosts_by_group_goo(self, group_goo):
+ group_dict = fc.get_groups()
+ hosts = fc.get_hosts_by_groupgoo(group_dict, group_goo)
+ print hosts
+
+class TestGroups(Groups):
+ def __init__(self):
+ self.minions = fc.Minions("@blippy", groups_file=GROUP_TEST)
+
+ def setUp(self):
+ self.gfb = GroupFileBuilder()
+ self.gfb.create({'blippy':[('host', 'localhost')]})
+
+ def test_get_host_by_group_goo(self):
+ results = self.minions.get_urls()
+ print results
+
+
+
+
# FIXME: comment this out till I setup a way to test with a speciic
# test config -akl