From be4f6ad065fa17ae34c810f2c09bc9f5fa4d9c23 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Tue, 14 Aug 2012 14:44:08 -0400 Subject: added unit tests for EntrySet --- testsuite/Testlib/TestServer/TestPlugins/TestProbes.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'testsuite/Testlib/TestServer/TestPlugins/TestProbes.py') diff --git a/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py b/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py index f90096210..0bcb65dc4 100644 --- a/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py +++ b/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py @@ -3,7 +3,7 @@ import sys import time import unittest import lxml.etree -from mock import Mock, patch +from mock import Mock, MagicMock, patch from ....common import * import Bcfg2.Server import Bcfg2.Server.Plugin @@ -75,18 +75,27 @@ class TestProbeData(Bcfg2TestCase): class TestProbeSet(TestEntrySet): test_obj = ProbeSet + basenames = ["test", "_test", "test-test"] + ignore = ["foo~", ".#foo", ".foo.swp", ".foo.swx", "probed.xml"] + bogus_names = ["test.py"] def get_obj(self, path=datastore, fam=None, encoding=None, - plugin_name="Probes"): + plugin_name="Probes", basename=None): + # get_obj() accepts the basename argument, accepted by the + # parent get_obj() method, and just throws it away, since + # ProbeSet uses a regex for the "basename" if fam is None: fam = Mock() - return self.test_obj(path, fam, encoding, plugin_name) + rv = self.test_obj(path, fam, encoding, plugin_name) + rv.entry_type = MagicMock() + return rv def test__init(self): fam = Mock() ps = self.get_obj(fam=fam) self.assertEqual(ps.plugin_name, "Probes") fam.AddMonitor.assert_called_with(datastore, ps) + TestEntrySet.test__init(self) def test_HandleEvent(self): ps = self.get_obj() -- cgit v1.2.3-1-g7c22