diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2008-01-19 04:05:42 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2008-01-19 04:05:42 +0000 |
commit | 33016cd1d7deeb9799b7b788d2dfccb18673437d (patch) | |
tree | ee4cb667ed9690a3fe7103b5190780a0c359b560 | |
parent | 538d451c22d2c6628f15f530ff621d96679cecb5 (diff) | |
download | bcfg2-33016cd1d7deeb9799b7b788d2dfccb18673437d.tar.gz bcfg2-33016cd1d7deeb9799b7b788d2dfccb18673437d.tar.bz2 bcfg2-33016cd1d7deeb9799b7b788d2dfccb18673437d.zip |
Add more testing for Bcfg2.Client.Frame (up to 66%) (woo!)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4268 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r-- | testsuite/TestFrame.py | 77 |
1 files changed, 73 insertions, 4 deletions
diff --git a/testsuite/TestFrame.py b/testsuite/TestFrame.py index 933298f06..453aabf85 100644 --- a/testsuite/TestFrame.py +++ b/testsuite/TestFrame.py @@ -10,16 +10,85 @@ class DriverInitFail(object): def __init__(self, *args): raise Bcfg2.Client.Tools.toolInstantiationError +class DriverInventoryFail(object): + __name__ = 'dif' + def __init__(self, logger, setup, config, states): + self.config = config + self.states = states + self.handled = [] + self.modified = [] + self.extra = [] + + def Inventory(self): + raise Error + + class TestFrame(object): def test__init(self): - config = lxml.etree.Element('Configuration') setup = {} times = {} - drivers = [] - frame = Bcfg2.Client.Frame.Frame(config, setup, times, drivers, False) + config = lxml.etree.Element('Configuration') + frame = Bcfg2.Client.Frame.Frame(config, setup, times, [], False) assert frame.tools == [] + + def test__init2(self): + setup = {} + times = {} frame2 = Bcfg2.Client.Frame.Frame(c1, setup, times, ['POSIX'], False) assert len(frame2.tools) == 1 + + def test__init3(self): + setup = {} + times = {} frame3 = Bcfg2.Client.Frame.Frame(c2, setup, times, ['foo'], False) assert len(frame3.tools) == 0 - frame4 = Bcfg2.Client.Frame.Frame(c2, setup, times, [DriverInitFail], False) + + def test__init4(self): + setup = {} + times = {} + frame = Bcfg2.Client.Frame.Frame(c2, setup, times, [DriverInitFail], False) + assert len(frame.tools) == 0 + + def test__Decide_Inventory(self): + setup = {'remove':'none', 'bundle':[], 'interactive':False} + times = {} + frame = Bcfg2.Client.Frame.Frame(c2, setup, times, + [DriverInventoryFail], False) + assert len(frame.tools) == 1 + frame.Inventory() + assert len([x for x in frame.states.values() if x]) == 0 + frame.Decide() + assert len(frame.whitelist) + + def test__Decide_Bundle(self): + setup = {'remove':'none', 'bundle':['bar'], 'interactive':False} + times = {} + frame = Bcfg2.Client.Frame.Frame(c2, setup, times, + [DriverInventoryFail], False) + assert len(frame.tools) == 1 + frame.Inventory() + assert len([x for x in frame.states.values() if x]) == 0 + frame.Decide() + assert len(frame.whitelist) == 0 + + def test__Decide_Dryrun(self): + setup = {'remove':'none', 'bundle':[], 'interactive':False} + times = {} + frame = Bcfg2.Client.Frame.Frame(c2, setup, times, + [DriverInventoryFail], True) + assert len(frame.tools) == 1 + frame.Inventory() + assert len([x for x in frame.states.values() if x]) == 0 + frame.Decide() + assert len(frame.whitelist) == 0 + + def test__GenerateStats(self): + setup = {'remove':'none', 'bundle':[], 'interactive':False} + times = {} + frame = Bcfg2.Client.Frame.Frame(c2, setup, times, + [DriverInventoryFail], False) + frame.Inventory() + frame.Decide() + stats = frame.GenerateStats() + assert len(stats.findall('.//Bad')[0].getchildren()) != 0 + |