From ef87028da290f8c196075f4e8154596329d56f15 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Mon, 29 Oct 2012 09:35:39 -0400 Subject: fixed unit tests --- .../Testsrc/Testlib/TestServer/TestPlugin/Testbase.py | 2 +- .../Testlib/TestServer/TestPlugins/TestMetadata.py | 17 +++++++++-------- testsuite/pylintrc.conf | 5 ++++- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'testsuite') diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testbase.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testbase.py index 7ee3697bb..f2cd39142 100644 --- a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testbase.py +++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testbase.py @@ -49,7 +49,7 @@ class TestDebuggable(Bcfg2TestCase): d.debug_flag = False d.debug_log("test") self.assertFalse(d.logger.error.called) - + d.logger.reset_mock() d.debug_log("test", flag=True) self.assertTrue(d.logger.error.called) diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py index 21502d1d8..b3d428642 100644 --- a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py +++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py @@ -102,7 +102,8 @@ class TestMetadataDB(DBModelTestCase): if HAS_DJANGO or can_skip: - class TestClientVersions(Bcfg2TestCase): + class TestClientVersions(TestDatabaseBacked): + test_obj = ClientVersions test_clients = dict(client1="1.2.0", client2="1.2.2", client3="1.3.0pre1", @@ -117,17 +118,17 @@ if HAS_DJANGO or can_skip: MetadataClientModel(hostname=client, version=version).save() def test__contains(self): - v = ClientVersions() + v = self.get_obj() self.assertIn("client1", v) self.assertIn("client5", v) self.assertNotIn("client__contains", v) def test_keys(self): - v = ClientVersions() + v = self.get_obj() self.assertItemsEqual(self.test_clients.keys(), v.keys()) def test__setitem(self): - v = ClientVersions() + v = self.get_obj() # test setting version of existing client v["client1"] = "1.2.3" @@ -153,7 +154,7 @@ if HAS_DJANGO or can_skip: self.assertEqual(client.version, None) def test__getitem(self): - v = ClientVersions() + v = self.get_obj() # test getting existing client self.assertEqual(v['client2'], "1.2.2") @@ -175,15 +176,15 @@ if HAS_DJANGO or can_skip: "%s not raised" % expected.__class__.__name__) def test__len(self): - v = ClientVersions() + v = self.get_obj() self.assertEqual(len(v), MetadataClientModel.objects.count()) def test__iter(self): - v = ClientVersions() + v = self.get_obj() self.assertItemsEqual([h for h in iter(v)], v.keys()) def test__delitem(self): - v = ClientVersions() + v = self.get_obj() # test adding new client new = "client__delitem" diff --git a/testsuite/pylintrc.conf b/testsuite/pylintrc.conf index 69b98b16e..829feaa26 100644 --- a/testsuite/pylintrc.conf +++ b/testsuite/pylintrc.conf @@ -33,7 +33,7 @@ load-plugins= # can either give multiple identifier separated by comma (,) or put this option # multiple time (only on the command line, not in the configuration file where # it should appear only once). -disable=F0401,W0142,W0511,W0603,W1201,R0201,R0801,R0901,R0902,R0903,R0904,R0921,R0922,C0302,I0011 +disable=F0401,W0142,W0511,W0603,W1201,R0201,R0801,R0901,R0902,R0903,R0904,R0921,R0922,C0302,I0011,E0100,E0101,E0102,E0106 # Some of these are disabled because they warn about things we _want_: # # * W0142: Used * or ** magic @@ -62,6 +62,9 @@ disable=F0401,W0142,W0511,W0603,W1201,R0201,R0801,R0901,R0902,R0903,R0904,R0921, # * R0801: Similar lines in files # * C0302: Too many lines in module +# Some of these are disabled because of bugs in pylint: +# * E0100,E0101,E0102,E0106: http://stackoverflow.com/questions/12514214/pylint-and-tornado-fails-on-tornado-web-authenticated + # Some of these are disabled for various other reasons: # * F0401: Unable to import a module: Bcfg2 has loads and loads of -- cgit v1.2.3-1-g7c22