Updated Branches: refs/heads/trunk 49dfd03c4 -> 354d2568d
AMBARI-2744. Python Unit tests broken (Andrew Onischuk via smohanty) Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/354d2568 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/354d2568 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/354d2568 Branch: refs/heads/trunk Commit: 354d2568d4c94f81e147604152529b7f364ff790 Parents: 49dfd03 Author: Sumit Mohanty <[email protected]> Authored: Tue Jul 30 14:44:24 2013 -0700 Committer: Sumit Mohanty <[email protected]> Committed: Tue Jul 30 14:44:24 2013 -0700 ---------------------------------------------------------------------- ambari-agent/src/test/python/TestHostCleanup.py | 5 ++++- ambari-agent/src/test/python/TestStatusCheck.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/354d2568/ambari-agent/src/test/python/TestHostCleanup.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/test/python/TestHostCleanup.py b/ambari-agent/src/test/python/TestHostCleanup.py index 601a87c..0bb513a 100644 --- a/ambari-agent/src/test/python/TestHostCleanup.py +++ b/ambari-agent/src/test/python/TestHostCleanup.py @@ -103,14 +103,17 @@ created = 2013-07-02 20:39:22.162757""" self.skip = skip self.verbose = False + @patch.object(HostCleanup.HostCleanup, 'do_cleanup') + @patch.object(HostCleanup.HostCleanup, 'is_current_user_root') @patch.object(logging.FileHandler, 'setFormatter') @patch.object(HostCleanup.HostCleanup,'read_host_check_file') @patch.object(logging,'basicConfig') @patch.object(logging, 'FileHandler') @patch.object(optparse.OptionParser, 'parse_args') - def test_options(self, parser_mock, file_handler_mock, logging_mock, read_host_check_file_mock, set_formatter_mock): + def test_options(self, parser_mock, file_handler_mock, logging_mock, read_host_check_file_mock, set_formatter_mock, user_root_mock, do_cleanup_mock): parser_mock.return_value = (TestHostCleanup.HostCleanupOptions('/someoutputfile', '/someinputfile', '', False), []) file_handler_mock.return_value = logging.FileHandler('') # disable creating real file + user_root_mock.return_value = True HostCleanup.main() # test --out http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/354d2568/ambari-agent/src/test/python/TestStatusCheck.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/test/python/TestStatusCheck.py b/ambari-agent/src/test/python/TestStatusCheck.py index 5432c76..5dac1de 100644 --- a/ambari-agent/src/test/python/TestStatusCheck.py +++ b/ambari-agent/src/test/python/TestStatusCheck.py @@ -97,7 +97,7 @@ class TestStatusCheck(TestCase): @patch.object(logger, 'info') def test_dont_relog_serToPidDict(self, logger_info_mock): TestStatusCheck.timesLogged = 0 - + def my_side_effect(*args, **kwargs): TestStatusCheck.timesLogged += args[0].find('Service to pid dictionary: ')+1 @@ -111,8 +111,8 @@ class TestStatusCheck(TestCase): self.globalConfig, self.servicesToLinuxUser) statusCheck = StatusCheck(self.serviceToPidDict, self.pidPathesVars, self.globalConfig, self.servicesToLinuxUser) - # and really only once logged - self.assertEqual(TestStatusCheck.timesLogged, 1) + # logged not more then once + self.assert_(TestStatusCheck.timesLogged <= 1, "test_dont_relog_serToPidDict logged more then once") # Ensure that status checker return True for running process even if multiple # pids for a service component exist
