Updated Branches: refs/heads/trunk 75b0c4400 -> ee4997c52
AMBARI-3107. Entering "n" to accept Oracle Binary license results in deprecation message (Dmytro Shkvyra via dlysnichenko) Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/ee4997c5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/ee4997c5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/ee4997c5 Branch: refs/heads/trunk Commit: ee4997c52b1845346bccd07c8f45c26d226bc9da Parents: 75b0c44 Author: Lisnichenko Dmitro <[email protected]> Authored: Thu Sep 5 14:47:29 2013 +0300 Committer: Lisnichenko Dmitro <[email protected]> Committed: Thu Sep 5 14:49:34 2013 +0300 ---------------------------------------------------------------------- ambari-server/src/main/python/ambari-server.py | 3 +- .../src/test/python/TestAmbaryServer.py | 31 +++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/ee4997c5/ambari-server/src/main/python/ambari-server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py index c77fdc2..820a405 100755 --- a/ambari-server/src/main/python/ambari-server.py +++ b/ambari-server/src/main/python/ambari-server.py @@ -1740,7 +1740,8 @@ def install_jdk(dest_file): "cancel the Ambari Server setup.\nDo you accept the " "Oracle Binary Code License Agreement [y/n] (y)? ", True) if not ok: - raise FatalException(1, None) + print 'Exiting...' + sys.exit(1) print "Installing JDK to {0}".format(JDK_INSTALL_DIR) retcode, out, err = run_os_command(CREATE_JDK_DIR_CMD) http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/ee4997c5/ambari-server/src/test/python/TestAmbaryServer.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/TestAmbaryServer.py b/ambari-server/src/test/python/TestAmbaryServer.py index fbaa210..c619c18 100644 --- a/ambari-server/src/test/python/TestAmbaryServer.py +++ b/ambari-server/src/test/python/TestAmbaryServer.py @@ -1521,7 +1521,36 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV os_path_exists_mock.return_value = False status, pid = ambari_server.is_server_runing() self.assertFalse(status) - + + + @patch("os.chdir") + @patch.object(ambari_server, "run_os_command") + @patch("sys.exit") + @patch.object(ambari_server, "get_YN_input") + def test_install_jdk(self, get_YN_input_mock, exit_mock, run_os_command_mock, os_chdir_mock): + get_YN_input_mock.return_value = False + JDK_INSTALL_DIR = "JDK_INSTALL_DIR" + run_os_command_mock.return_value = 0, "", "" + ambari_server.install_jdk(MagicMock()) + self.assertTrue(exit_mock.called) + exit_mock.reset() + run_os_command_mock.reset() + exit_mock.called = False + run_os_command_mock.call_count = 0 + get_YN_input_mock.return_value = True + ambari_server.install_jdk(MagicMock()) + self.assertFalse(exit_mock.called) + self.assertEquals(3, run_os_command_mock.call_count) + run_os_command_mock.return_value = 1, "", "" + failed = False + try: + ambari_server.install_jdk(MagicMock()) + self.fail("Exception was not rised!") + except FatalException: + failed = True + self.assertTrue(failed) + + @patch.object(ambari_server, "install_jce_manualy") @patch("os.stat") @patch("os.path.isfile")
