incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smoha...@apache.org
Subject [2/3] AMBARI-3217. ambari-server unit tests produce leave behind an ambari.properties file within the enlistment (formatting clean up).
Date Thu, 12 Sep 2013 23:10:33 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/2df4a6e0/ambari-server/src/test/python/TestAmbariServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py
index 0034388..a097130 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -37,7 +37,6 @@ NonFatalException = ambari_server.NonFatalException
 
 
 class TestAmbariServer(TestCase):
-
   def setUp(self):
     out = StringIO.StringIO()
     sys.stdout = out
@@ -51,8 +50,8 @@ class TestAmbariServer(TestCase):
   @patch.object(ambari_server, 'run_os_command')
   @patch('optparse.Values')
   def test_configure_pg_hba_ambaridb_users(self, OptParseValuesMock,
-                                run_os_command_method,
-                                configure_database_username_password_method):
+                                           run_os_command_method,
+                                           configure_database_username_password_method):
     # Prepare mocks
     run_os_command_method.return_value = (0, "", "")
     opvm = OptParseValuesMock.return_value
@@ -65,7 +64,7 @@ class TestAmbariServer(TestCase):
     self.assertTrue(run_os_command_method.called)
     self.assertTrue(configure_database_username_password_method.called)
     string_expected = self.get_file_string(self
-      .get_samples_dir("configure_pg_hba_ambaridb_users1"))
+    .get_samples_dir("configure_pg_hba_ambaridb_users1"))
     string_actual = self.get_file_string(ambari_server.PG_HBA_CONF_FILE)
     self.assertEquals(string_expected, string_actual)
     pass
@@ -79,7 +78,7 @@ class TestAmbariServer(TestCase):
     result = ambari_server.get_validated_service_name("ambari", 1)
     self.assertEqual("OT100", result, "Not accepting digits")
     pass
-    
+
   @patch('__builtin__.raw_input')
   def test_dbname_regex(self, raw_input_method):
 
@@ -88,7 +87,7 @@ class TestAmbariServer(TestCase):
     raw_input_method.return_value = "OT100"
     result = ambari_server.get_validated_db_name("ambari")
     self.assertEqual("OT100", result, "Not accepting digits")
- 
+
 
   def test_configure_pg_hba_postgres_user(self):
 
@@ -103,7 +102,7 @@ class TestAmbariServer(TestCase):
 
     ambari_server.configure_pg_hba_postgres_user()
 
-    expected  = self.get_file_string(self.get_samples_dir(
+    expected = self.get_file_string(self.get_samples_dir(
       "configure_pg_hba_ambaridb_users2"))
     result = self.get_file_string(ambari_server.PG_HBA_CONF_FILE)
     self.assertEqual(expected, result, "pg_hba_conf not processed")
@@ -113,18 +112,17 @@ class TestAmbariServer(TestCase):
     self.assertEqual("0644", str_mode, "Wrong file permissions")
 
 
-
   @patch('__builtin__.raw_input')
   def get_choice_string_input(self, raw_input_method):
     prompt = "blablabla"
     default = "default blablabla"
-    firstChoice = set(['yes','ye', 'y'])
-    secondChoice = set(['no','n'])
+    firstChoice = set(['yes', 'ye', 'y'])
+    secondChoice = set(['no', 'n'])
     # test first input
     raw_input_method.return_value = "Y"
 
     result = ambari_server.get_choice_string_input(prompt, default,
-        firstChoice, secondChoice)
+                                                   firstChoice, secondChoice)
     self.assertEquals(result, True)
     raw_input_method.reset_mock()
     # test second input
@@ -132,7 +130,7 @@ class TestAmbariServer(TestCase):
     raw_input_method.return_value = "N"
 
     result = ambari_server.get_choice_string_input(prompt, default,
-        firstChoice, secondChoice)
+                                                   firstChoice, secondChoice)
     self.assertEquals(result, False)
 
     raw_input_method.reset_mock()
@@ -142,31 +140,32 @@ class TestAmbariServer(TestCase):
     raw_input_method.return_value = ""
 
     result = ambari_server.get_choice_string_input(prompt, default,
-        firstChoice, secondChoice)
+                                                   firstChoice, secondChoice)
     self.assertEquals(result, default)
 
     raw_input_method.reset_mock()
 
     # test wrong input
-    list_of_return_values= ['yes', 'dsad', 'fdsfds']
+    list_of_return_values = ['yes', 'dsad', 'fdsfds']
+
     def side_effect(list):
       return list_of_return_values.pop()
+
     raw_input_method.side_effect = side_effect
 
     result = ambari_server.get_choice_string_input(prompt, default,
-        firstChoice, secondChoice)
+                                                   firstChoice, secondChoice)
     self.assertEquals(result, True)
     self.assertEquals(raw_input_method.call_count, 3)
 
     pass
 
 
-
   @patch('re.search')
   @patch('__builtin__.raw_input')
   @patch('getpass.getpass')
   def get_validated_string_input(self, get_pass_method,
-      raw_input_method, re_search_method):
+                                 raw_input_method, re_search_method):
     prompt = "blabla"
     default = "default_pass"
     pattern = "pattern_pp"
@@ -177,7 +176,7 @@ class TestAmbariServer(TestCase):
     get_pass_method.return_value = "dfdsfdsfds"
 
     result = ambari_server.get_validated_string_input(prompt, default,
-        pattern, description, is_pass)
+                                                      pattern, description, is_pass)
 
     self.assertEquals(get_pass_method.return_value, result)
     get_pass_method.assure_called_once(prompt)
@@ -190,14 +189,13 @@ class TestAmbariServer(TestCase):
     raw_input_method.return_value = "dkf90ewuf0"
 
     result = ambari_server.get_validated_string_input(prompt, default,
-        pattern, description, is_pass)
+                                                      pattern, description, is_pass)
 
     self.assertEquals(raw_input_method.return_value, result)
     self.assertFalse(get_pass_method.called)
     raw_input_method.assure_called_once(prompt)
 
 
-
   def test_get_pass_file_path(self):
     result = ambari_server.get_pass_file_path("/etc/ambari/conf_file")
     self.assertEquals("/etc/ambari/password.dat", result)
@@ -212,27 +210,27 @@ class TestAmbariServer(TestCase):
   @patch.object(ambari_server, 'reset')
   @patch('optparse.OptionParser')
   def test_main_test_setup_https(self, OptionParserMock, reset_method, stop_method,
-                           start_method, setup_method, setup_https_method, is_server_runing_method):
-      opm = OptionParserMock.return_value
-      options = MagicMock()
-      args = ["setup-https"]
-      opm.parse_args.return_value = (options, args)
-      setup_https_method.return_value = False
-      is_server_runing_method.return_value = (False, None)
-
-      options.database=None
-      options.sid_or_sname = "sid"
-      ambari_server.main()
+                                 start_method, setup_method, setup_https_method, is_server_runing_method):
+    opm = OptionParserMock.return_value
+    options = MagicMock()
+    args = ["setup-https"]
+    opm.parse_args.return_value = (options, args)
+    setup_https_method.return_value = False
+    is_server_runing_method.return_value = (False, None)
 
-      self.assertTrue(setup_https_method.called)
-      self.assertEqual(is_server_runing_method.call_count, 0)
-      is_server_runing_method.reset()
-      setup_https_method.return_value = True
-      ambari_server.main()
-      self.assertTrue(setup_https_method.called)
-      self.assertEqual(is_server_runing_method.call_count, 1)
-      self.assertFalse(False, ambari_server.VERBOSE)
-      self.assertFalse(False, ambari_server.SILENT)
+    options.database = None
+    options.sid_or_sname = "sid"
+    ambari_server.main()
+
+    self.assertTrue(setup_https_method.called)
+    self.assertEqual(is_server_runing_method.call_count, 0)
+    is_server_runing_method.reset()
+    setup_https_method.return_value = True
+    ambari_server.main()
+    self.assertTrue(setup_https_method.called)
+    self.assertEqual(is_server_runing_method.call_count, 1)
+    self.assertFalse(False, ambari_server.VERBOSE)
+    self.assertFalse(False, ambari_server.SILENT)
 
   @patch.object(ambari_server, 'setup')
   @patch.object(ambari_server, 'start')
@@ -246,7 +244,7 @@ class TestAmbariServer(TestCase):
     args = ["setup"]
     opm.parse_args.return_value = (options, args)
 
-    options.database=None
+    options.database = None
     options.sid_or_sname = "sid"
     ambari_server.main()
 
@@ -271,7 +269,7 @@ class TestAmbariServer(TestCase):
     args = ["setup"]
     opm.parse_args.return_value = (options, args)
 
-    options.database=None
+    options.database = None
     options.sid_or_sname = "sname"
     ambari_server.main()
 
@@ -284,20 +282,19 @@ class TestAmbariServer(TestCase):
     self.assertFalse(False, ambari_server.SILENT)
 
 
-
   @patch.object(ambari_server, 'setup')
   @patch.object(ambari_server, 'start')
   @patch.object(ambari_server, 'stop')
   @patch.object(ambari_server, 'reset')
   @patch('optparse.OptionParser')
   def test_main_test_start_debug_short(self, OptionParserMock, reset_method, stop_method,
-                           start_method, setup_method):
+                                       start_method, setup_method):
     opm = OptionParserMock.return_value
     options = MagicMock()
     args = ["start", "-g"]
     opm.parse_args.return_value = (options, args)
 
-    options.database=None
+    options.database = None
     options.sid_or_sname = "sid"
 
     ambari_server.main()
@@ -307,8 +304,7 @@ class TestAmbariServer(TestCase):
     self.assertFalse(stop_method.called)
     self.assertFalse(reset_method.called)
 
-    self.assertTrue(ambari_server.SERVER_DEBUG_MODE)  
-
+    self.assertTrue(ambari_server.SERVER_DEBUG_MODE)
 
 
   @patch.object(ambari_server, 'setup')
@@ -317,12 +313,12 @@ class TestAmbariServer(TestCase):
   @patch.object(ambari_server, 'reset')
   @patch('optparse.OptionParser')
   def test_main_test_start_debug_long(self, OptionParserMock, reset_method, stop_method,
-                           start_method, setup_method):
+                                      start_method, setup_method):
     opm = OptionParserMock.return_value
     options = MagicMock()
     args = ["start", "--debug"]
     opm.parse_args.return_value = (options, args)
-    options.database=None
+    options.database = None
     options.sid_or_sname = "sid"
 
     ambari_server.main()
@@ -373,7 +369,7 @@ class TestAmbariServer(TestCase):
     options = MagicMock()
     args = ["reset"]
     opm.parse_args.return_value = (options, args)
-    options.database=None
+    options.database = None
     options.sid_or_sname = "sid"
 
     ambari_server.main()
@@ -397,7 +393,7 @@ class TestAmbariServer(TestCase):
 
     ambari_server.configure_postgresql_conf()
 
-    expected  = self.get_file_string(self.get_samples_dir(
+    expected = self.get_file_string(self.get_samples_dir(
       "configure_postgresql_conf1"))
     result = self.get_file_string(ambari_server.POSTGRESQL_CONF_FILE)
     self.assertEqual(expected, result, "postgresql.conf not updated")
@@ -429,7 +425,7 @@ class TestAmbariServer(TestCase):
     sys.stdout = sys.__stdout__
     self.assertEqual(0, rcode)
     self.assertEqual("Backup for pg_hba found, reconfiguration not required\n",
-      out.getvalue())
+                     out.getvalue())
 
     ambari_server.PG_HBA_CONF_FILE_BACKUP = tempfile.mktemp()
     get_postgre_status_mock.return_value = ambari_server.PG_STATUS_RUNNING
@@ -438,7 +434,7 @@ class TestAmbariServer(TestCase):
     rcode = ambari_server.configure_postgres()
 
     self.assertTrue(os.path.isfile(ambari_server.PG_HBA_CONF_FILE_BACKUP),
-      "postgresql.conf backup not created")
+                    "postgresql.conf backup not created")
     self.assertTrue(configure_pg_hba_postgres_user_mock.called)
     self.assertTrue(configure_pg_hba_ambaridb_users_mock.called)
     mode = oct(os.stat(ambari_server.PG_HBA_CONF_FILE)[stat.ST_MODE])
@@ -455,7 +451,6 @@ class TestAmbariServer(TestCase):
     sys.stdout = sys.__stdout__
 
 
-
   @patch("time.sleep")
   @patch("subprocess.Popen")
   @patch.object(ambari_server, "run_os_command")
@@ -476,7 +471,6 @@ class TestAmbariServer(TestCase):
     self.assertEqual(1, rcode)
 
 
-
   @patch("shlex.split")
   @patch("subprocess.Popen")
   @patch.object(ambari_server, "print_info_msg")
@@ -498,7 +492,6 @@ class TestAmbariServer(TestCase):
     self.assertTrue(splitMock.called)
 
 
-
   @patch.object(ambari_server, "get_conf_dir")
   @patch.object(ambari_server, "search_file")
   def test_write_property(self, search_file_mock, get_conf_dir_mock):
@@ -512,7 +505,6 @@ class TestAmbariServer(TestCase):
     self.assertTrue(expected_content in result)
 
 
-
   @patch.object(ambari_server, "configure_database_username_password")
   @patch.object(ambari_server, "run_os_command")
   def test_setup_db(self, run_os_command_mock,
@@ -528,7 +520,7 @@ class TestAmbariServer(TestCase):
   @patch.object(ambari_server, "run_os_command")
   def test_setup_db_connect_attempts_fail(self, run_os_command_mock,
                                           sleep_mock, config_db_mock):
-    run_os_command_mock.side_effect = [(1, "error", "error"),(1, "error", "error"),
+    run_os_command_mock.side_effect = [(1, "error", "error"), (1, "error", "error"),
                                        (1, "error", "error")]
     result = ambari_server.setup_db(MagicMock())
     self.assertTrue(run_os_command_mock.called)
@@ -541,7 +533,7 @@ class TestAmbariServer(TestCase):
   @patch.object(ambari_server, "run_os_command")
   def test_setup_db_connect_attempts_success(self, run_os_command_mock,
                                              sleep_mock, config_db_mock):
-    run_os_command_mock.side_effect = [(1, "error", "error"),(0, None, None),
+    run_os_command_mock.side_effect = [(1, "error", "error"), (0, None, None),
                                        (0, None, None)]
     result = ambari_server.setup_db(MagicMock())
     self.assertTrue(run_os_command_mock.called)
@@ -558,8 +550,8 @@ class TestAmbariServer(TestCase):
     self.assertEqual(0, rcode)
 
     getYNInput_mock.return_value = True
-    run_os_command_mock.return_value = (0,"enabled "
-                                          + ambari_server.SE_MODE_ENFORCING,
+    run_os_command_mock.return_value = (0, "enabled "
+                                           + ambari_server.SE_MODE_ENFORCING,
                                         None)
     rcode = ambari_server.check_selinux()
     self.assertEqual(0, rcode)
@@ -567,7 +559,6 @@ class TestAmbariServer(TestCase):
     self.assertTrue(getYNInput_mock.called)
 
 
-
   @patch.object(ambari_server, "print_info_msg")
   def test_get_ambari_jars(self, printInfoMsg_mock):
 
@@ -673,8 +664,8 @@ class TestAmbariServer(TestCase):
   @patch.object(ambari_server, "get_value_from_properties")
   @patch("os.mkdir")
   def test_adjust_directory_permissions(self, mkdir_mock,
-            get_value_from_properties_mock, get_ambari_properties_mock,
-            run_os_command_mock, set_file_permissions_mock, exists_mock):
+                                        get_value_from_properties_mock, get_ambari_properties_mock,
+                                        run_os_command_mock, set_file_permissions_mock, exists_mock):
     # Testing boostrap dir wipe
     properties_mock = MagicMock()
     get_value_from_properties_mock.return_value = "dummy_bootstrap_dir"
@@ -778,13 +769,12 @@ class TestAmbariServer(TestCase):
     print_warning_msg_mock.reset_mock()
 
 
-
   @patch.object(ambari_server, "get_validated_string_input")
   @patch.object(ambari_server, "print_info_msg")
   @patch.object(ambari_server, "print_warning_msg")
   @patch.object(ambari_server, "run_os_command")
   def test_create_custom_user(self, run_os_command_mock, print_warning_msg_mock,
-          print_info_msg_mock, get_validated_string_input_mock):
+                              print_info_msg_mock, get_validated_string_input_mock):
     user = "dummy-user"
     get_validated_string_input_mock.return_value = user
 
@@ -815,7 +805,6 @@ class TestAmbariServer(TestCase):
     self.assertEquals(result, (1, None))
 
 
-
   @patch.object(ambari_server, "read_ambari_user")
   @patch.object(ambari_server, "get_YN_input")
   @patch.object(ambari_server, "create_custom_user")
@@ -823,8 +812,8 @@ class TestAmbariServer(TestCase):
   @patch.object(ambari_server, "adjust_directory_permissions")
   @patch.object(ambari_server, "print_error_msg")
   def test_check_ambari_user(self, print_error_msg_mock,
-            adjust_directory_permissions_mock, write_property_mock,
-            create_custom_user_mock, get_YN_input_mock, read_ambari_user_mock):
+                             adjust_directory_permissions_mock, write_property_mock,
+                             create_custom_user_mock, get_YN_input_mock, read_ambari_user_mock):
 
     # Scenario: user is already defined, user does not want to reconfigure it
     read_ambari_user_mock.return_value = "dummy-user"
@@ -945,7 +934,7 @@ class TestAmbariServer(TestCase):
   @patch.object(ambari_server, "read_ambari_user")
   @patch.object(ambari_server, "set_file_permissions")
   def test_store_password_file(self, set_file_permissions_mock,
-                    read_ambari_user_mock, open_mock, search_file_mock):
+                               read_ambari_user_mock, open_mock, search_file_mock):
     search_file_mock.return_value = "/etc/ambari-server/conf/ambari.properties"
     open_mock.return_value = MagicMock()
     ambari_server.store_password_file("password", "passfile")
@@ -980,10 +969,12 @@ class TestAmbariServer(TestCase):
   def test_track_jdk(self, dlprogress_mock, openMock, urlopenMock):
 
     u = MagicMock()
-    u.info.return_value = {"Content-Length":"24576"}
+    u.info.return_value = {"Content-Length": "24576"}
     chunks = [None, "second", "first"]
+
     def side_effect(*args, **kwargs):
       return chunks.pop()
+
     u.read.side_effect = side_effect
     urlopenMock.return_value = u
 
@@ -1003,8 +994,8 @@ class TestAmbariServer(TestCase):
   @patch("os.path.join")
   @patch("os.path.exists")
   @patch.object(ambari_server, "get_ambari_properties")
-  def test_install_jce_manualy(self, get_ambari_properties_mock,\
-                               os_path_exists_mock, os_path_join_mock,\
+  def test_install_jce_manualy(self, get_ambari_properties_mock, \
+                               os_path_exists_mock, os_path_join_mock, \
                                shutil_copy_mock):
     args = MagicMock()
     args.jce_policy = "somewhere"
@@ -1014,8 +1005,8 @@ class TestAmbariServer(TestCase):
     p.__getitem__.return_value = "somewhere"
     os_path_exists_mock.return_value = True
     os_path_join_mock.return_value = \
-                            "/var/lib/ambari-server/resources/jce_policy-6.zip" 
-    ambari_server.install_jce_manualy(args)	
+      "/var/lib/ambari-server/resources/jce_policy-6.zip"
+    ambari_server.install_jce_manualy(args)
     self.assertTrue(shutil_copy_mock.called)
 
     shutil_copy_mock.side_effect = Exception("exception")
@@ -1023,9 +1014,9 @@ class TestAmbariServer(TestCase):
       ambari_server.install_jce_manualy(args)
       self.fail("Should throw exception because of not found jce_policy-6.zip")
     except Exception:
-       # Expected
+    # Expected
       self.assertTrue(shutil_copy_mock.called)
-      pass  
+      pass
 
     shutil_copy_mock.side_effect = None
     args.jce_policy = None
@@ -1037,23 +1028,23 @@ class TestAmbariServer(TestCase):
   @patch.object(ambari_server, "find_properties_file")
   @patch.object(ambari_server, "get_ambari_properties")
   @patch.object(ambari_server, "is_server_runing")
-  @patch.object(ambari_server, "import_cert_and_key_action")  
-  @patch.object(ambari_server, "get_YN_input")  
+  @patch.object(ambari_server, "import_cert_and_key_action")
+  @patch.object(ambari_server, "get_YN_input")
   @patch("__builtin__.open")
   @patch("ambari-server.Properties")
   @patch.object(ambari_server, "is_root")
-  @patch.object(ambari_server, "is_valid_cert_host")  
-  @patch.object(ambari_server, "is_valid_cert_exp") 
-  def test_setup_https(self, is_valid_cert_exp_mock, is_valid_cert_host_mock,\
-                       is_root_mock, Properties_mock, open_Mock, get_YN_input_mock,\
+  @patch.object(ambari_server, "is_valid_cert_host")
+  @patch.object(ambari_server, "is_valid_cert_exp")
+  def test_setup_https(self, is_valid_cert_exp_mock, is_valid_cert_host_mock, \
+                       is_root_mock, Properties_mock, open_Mock, get_YN_input_mock, \
                        import_cert_and_key_action_mock,
-                       is_server_runing_mock, get_ambari_properties_mock,\
-                       find_properties_file_mock,\
+                       is_server_runing_mock, get_ambari_properties_mock, \
+                       find_properties_file_mock, \
                        get_validated_string_input_mock,
                        read_ambari_user_method):
-      
-    is_valid_cert_exp_mock.return_value=True
-    is_valid_cert_host_mock.return_value=True
+
+    is_valid_cert_exp_mock.return_value = True
+    is_valid_cert_host_mock.return_value = True
     args = MagicMock()
     open_Mock.return_value = file
     p = get_ambari_properties_mock.return_value
@@ -1073,16 +1064,16 @@ class TestAmbariServer(TestCase):
     read_ambari_user_method.return_value = None
     #Case #1: if client ssl is on and user didnt choose 
     #disable ssl option and choose import certs and keys
-    p.get_property.side_effect = ["key_dir","5555","6666", "true"]
-    get_YN_input_mock.side_effect = [False,True]
+    p.get_property.side_effect = ["key_dir", "5555", "6666", "true"]
+    get_YN_input_mock.side_effect = [False, True]
     get_validated_string_input_mock.side_effect = ["4444"]
-    get_property_expected = "[call('security.server.keys_dir'),\n"+\
-                            " call('client.api.ssl.port'),\n"+\
+    get_property_expected = "[call('security.server.keys_dir'),\n" + \
+                            " call('client.api.ssl.port'),\n" + \
                             " call('client.api.ssl.port'),\n call('api.ssl')]"
     process_pair_expected = "[call('client.api.ssl.port', '4444')]"
     ambari_server.SILENT = False
     ambari_server.setup_https(args)
-    
+
     self.assertTrue(p.process_pair.called)
     self.assertTrue(p.get_property.call_count == 4)
     self.assertEqual(str(p.get_property.call_args_list), get_property_expected)
@@ -1096,14 +1087,14 @@ class TestAmbariServer(TestCase):
     import_cert_and_key_action_mock.reset_mock()
 
     #Case #2: if client ssl is on and user choose to disable ssl option
-    p.get_property.side_effect = ["key_dir","", "true"]
+    p.get_property.side_effect = ["key_dir", "", "true"]
     get_YN_input_mock.side_effect = [True]
     get_validated_string_input_mock.side_effect = ["4444"]
-    get_property_expected = "[call('security.server.keys_dir'),\n"+\
+    get_property_expected = "[call('security.server.keys_dir'),\n" + \
                             " call('client.api.ssl.port'),\n call('api.ssl')]"
     process_pair_expected = "[call('api.ssl', 'false')]"
     ambari_server.setup_https(args)
-    
+
     self.assertTrue(p.process_pair.called)
     self.assertTrue(p.get_property.call_count == 3)
     self.assertEqual(str(p.get_property.call_args_list), get_property_expected)
@@ -1118,10 +1109,10 @@ class TestAmbariServer(TestCase):
 
     #Case #3: if client ssl is off and user choose option 
     #to import cert and keys
-    p.get_property.side_effect = ["key_dir","", None]
+    p.get_property.side_effect = ["key_dir", "", None]
     get_YN_input_mock.side_effect = [True, True]
     get_validated_string_input_mock.side_effect = ["4444"]
-    get_property_expected = "[call('security.server.keys_dir'),\n"+\
+    get_property_expected = "[call('security.server.keys_dir'),\n" + \
                             " call('client.api.ssl.port'),\n call('api.ssl')]"
     process_pair_expected = "[call('client.api.ssl.port', '4444')]"
     ambari_server.setup_https(args)
@@ -1137,14 +1128,14 @@ class TestAmbariServer(TestCase):
     p.get_property.reset_mock()
     p.store.reset_mock()
     import_cert_and_key_action_mock.reset_mock()
-    
+
     #Case #4: if client ssl is off and 
     #user did not choose option to import cert and keys
-    p.get_property.side_effect = ["key_dir","", None]
+    p.get_property.side_effect = ["key_dir", "", None]
     get_YN_input_mock.side_effect = [False]
     get_validated_string_input_mock.side_effect = ["4444"]
-    get_property_expected = "[call('security.server.keys_dir'),\n"+\
-    " call('client.api.ssl.port'),\n call('api.ssl')]"
+    get_property_expected = "[call('security.server.keys_dir'),\n" + \
+                            " call('client.api.ssl.port'),\n call('api.ssl')]"
     process_pair_expected = "[]"
     ambari_server.setup_https(args)
 
@@ -1168,21 +1159,21 @@ class TestAmbariServer(TestCase):
     except NonFatalException as fe:
       self.assertTrue("setup-https is not enabled in silent mode" in fe.reason)
 
-    
+
   @patch.object(ambari_server, "import_cert_and_key")
   def test_import_cert_and_key_action(self, import_cert_and_key_mock):
     import_cert_and_key_mock.return_value = True
     properties = MagicMock()
-    properties.get_property.side_effect = ["key_dir","5555","6666", "true"]
+    properties.get_property.side_effect = ["key_dir", "5555", "6666", "true"]
     properties.process_pair = MagicMock()
-    expect_process_pair = "[call('client.api.ssl.cert_name', 'https.crt'),\n"+\
-                          " call('client.api.ssl.key_name', 'https.key'),\n"+\
+    expect_process_pair = "[call('client.api.ssl.cert_name', 'https.crt'),\n" + \
+                          " call('client.api.ssl.key_name', 'https.key'),\n" + \
                           " call('api.ssl', 'true')]"
     ambari_server.import_cert_and_key_action("key_dir", properties)
-  	
-    self.assertEqual(str(properties.process_pair.call_args_list),\
+
+    self.assertEqual(str(properties.process_pair.call_args_list), \
                      expect_process_pair)
-    
+
   @patch.object(ambari_server, "remove_file")
   @patch.object(ambari_server, "copy_file")
   @patch.object(ambari_server, "read_ambari_user")
@@ -1193,35 +1184,35 @@ class TestAmbariServer(TestCase):
   @patch("os.path.join")
   @patch.object(ambari_server, "get_validated_filepath_input")
   @patch.object(ambari_server, "get_validated_string_input")
-  @patch.object(ambari_server, "is_valid_cert_host")  
-  @patch.object(ambari_server, "is_valid_cert_exp")  
-  def test_import_cert_and_key(self,is_valid_cert_exp_mock,\
-                               is_valid_cert_host_mock,\
-                               get_validated_string_input_mock,\
-                               get_validated_filepath_input_mock,\
-                               os_path_join_mock, run_os_command_mock,\
-                               open_mock, import_file_to_keystore_mock,\
-                               set_file_permissions_mock, read_ambari_user_mock, copy_file_mock,\
+  @patch.object(ambari_server, "is_valid_cert_host")
+  @patch.object(ambari_server, "is_valid_cert_exp")
+  def test_import_cert_and_key(self, is_valid_cert_exp_mock, \
+                               is_valid_cert_host_mock, \
+                               get_validated_string_input_mock, \
+                               get_validated_filepath_input_mock, \
+                               os_path_join_mock, run_os_command_mock, \
+                               open_mock, import_file_to_keystore_mock, \
+                               set_file_permissions_mock, read_ambari_user_mock, copy_file_mock, \
                                remove_file_mock):
-    is_valid_cert_exp_mock.return_value=True
-    is_valid_cert_host_mock.return_value=True
+    is_valid_cert_exp_mock.return_value = True
+    is_valid_cert_host_mock.return_value = True
     get_validated_string_input_mock.return_value = "password"
     get_validated_filepath_input_mock.side_effect = \
-                                            ["cert_file_path","key_file_path"]
-    os_path_join_mock.side_effect = ["keystore_file_path", "keystore_file_path_tmp",\
-                                     "pass_file_path", "pass_file_path_tmp",\
-                                     "passin_file_path","password_file_path",\
-                                     "keystore_cert_file_path",\
-                                     "keystore_cert_key_file_path",]
-    run_os_command_mock.return_value = (0, "",	"")
+      ["cert_file_path", "key_file_path"]
+    os_path_join_mock.side_effect = ["keystore_file_path", "keystore_file_path_tmp", \
+                                     "pass_file_path", "pass_file_path_tmp", \
+                                     "passin_file_path", "password_file_path", \
+                                     "keystore_cert_file_path", \
+                                     "keystore_cert_key_file_path", ]
+    run_os_command_mock.return_value = (0, "", "")
     om = open_mock.return_value
-    expect_import_file_to_keystore = "[call('keystore_file_path_tmp',"+\
-                                     " 'keystore_file_path'),\n"+\
-                                     " call('pass_file_path_tmp',"+\
-                                     " 'pass_file_path'),\n"+\
-                                     " call('cert_file_path',"+\
-                                     " 'keystore_cert_file_path'),\n"+\
-                                     " call('key_file_path',"+\
+    expect_import_file_to_keystore = "[call('keystore_file_path_tmp'," + \
+                                     " 'keystore_file_path'),\n" + \
+                                     " call('pass_file_path_tmp'," + \
+                                     " 'pass_file_path'),\n" + \
+                                     " call('cert_file_path'," + \
+                                     " 'keystore_cert_file_path'),\n" + \
+                                     " call('key_file_path'," + \
                                      " 'keystore_cert_key_file_path')]"
 
     ambari_server.import_cert_and_key("key_dir")
@@ -1229,8 +1220,8 @@ class TestAmbariServer(TestCase):
     self.assertTrue(get_validated_string_input_mock.called)
     self.assertEqual(os_path_join_mock.call_count, 8)
     self.assertTrue(set_file_permissions_mock.call_count == 1)
-    self.assertEqual(str(import_file_to_keystore_mock.call_args_list),\
-                         expect_import_file_to_keystore)
+    self.assertEqual(str(import_file_to_keystore_mock.call_args_list), \
+                     expect_import_file_to_keystore)
 
   @patch.object(ambari_server, "remove_file")
   @patch.object(ambari_server, "copy_file")
@@ -1243,35 +1234,35 @@ class TestAmbariServer(TestCase):
   @patch("os.path.join")
   @patch.object(ambari_server, "get_validated_filepath_input")
   @patch.object(ambari_server, "get_validated_string_input")
-  @patch.object(ambari_server, "is_valid_cert_host")  
-  @patch.object(ambari_server, "is_valid_cert_exp")  
+  @patch.object(ambari_server, "is_valid_cert_host")
+  @patch.object(ambari_server, "is_valid_cert_exp")
   def test_import_cert_and_key_with_empty_password(self, \
-    is_valid_cert_exp_mock, is_valid_cert_host_mock,                                         
-    get_validated_string_input_mock, get_validated_filepath_input_mock,\
-    os_path_join_mock, run_os_command_mock, open_mock, \
-    import_file_to_keystore_mock, set_file_permissions_mock,
-    read_ambari_user_mock, generate_random_string_mock, copy_file_mock,\
-    remove_file_mock):
-      
-    is_valid_cert_exp_mock.return_value=True
-    is_valid_cert_host_mock.return_value=True
+                                                   is_valid_cert_exp_mock, is_valid_cert_host_mock,
+                                                   get_validated_string_input_mock, get_validated_filepath_input_mock, \
+                                                   os_path_join_mock, run_os_command_mock, open_mock, \
+                                                   import_file_to_keystore_mock, set_file_permissions_mock,
+                                                   read_ambari_user_mock, generate_random_string_mock, copy_file_mock, \
+                                                   remove_file_mock):
+
+    is_valid_cert_exp_mock.return_value = True
+    is_valid_cert_host_mock.return_value = True
     get_validated_string_input_mock.return_value = ""
-    get_validated_filepath_input_mock.side_effect =\
-    ["cert_file_path","key_file_path"]
-    os_path_join_mock.side_effect = ["keystore_file_path", "keystore_file_path_tmp",\
-                                     "pass_file_path", "pass_file_path_tmp",\
-                                     "passin_file_path","password_file_path",\
-                                     "keystore_cert_file_path",\
-                                     "keystore_cert_key_file_path",]
-    run_os_command_mock.return_value = (0, "",	"")
-
-    expect_import_file_to_keystore = "[call('keystore_file_path_tmp',"+\
-                                     " 'keystore_file_path'),\n"+\
-                                     " call('pass_file_path_tmp',"+\
-                                     " 'pass_file_path'),\n"+\
-                                     " call('cert_file_path',"+\
-                                     " 'keystore_cert_file_path'),\n"+\
-                                     " call('key_file_path.secured',"+\
+    get_validated_filepath_input_mock.side_effect = \
+      ["cert_file_path", "key_file_path"]
+    os_path_join_mock.side_effect = ["keystore_file_path", "keystore_file_path_tmp", \
+                                     "pass_file_path", "pass_file_path_tmp", \
+                                     "passin_file_path", "password_file_path", \
+                                     "keystore_cert_file_path", \
+                                     "keystore_cert_key_file_path", ]
+    run_os_command_mock.return_value = (0, "", "")
+
+    expect_import_file_to_keystore = "[call('keystore_file_path_tmp'," + \
+                                     " 'keystore_file_path'),\n" + \
+                                     " call('pass_file_path_tmp'," + \
+                                     " 'pass_file_path'),\n" + \
+                                     " call('cert_file_path'," + \
+                                     " 'keystore_cert_file_path'),\n" + \
+                                     " call('key_file_path.secured'," + \
                                      " 'keystore_cert_key_file_path')]"
 
     ambari_server.import_cert_and_key("key_dir")
@@ -1279,8 +1270,8 @@ class TestAmbariServer(TestCase):
     self.assertTrue(get_validated_string_input_mock.called)
     self.assertEquals(os_path_join_mock.call_count, 8)
     self.assertEquals(set_file_permissions_mock.call_count, 1)
-    self.assertEqual(str(import_file_to_keystore_mock.call_args_list),\
-      expect_import_file_to_keystore)
+    self.assertEqual(str(import_file_to_keystore_mock.call_args_list), \
+                     expect_import_file_to_keystore)
     self.assertTrue(generate_random_string_mock.called)
 
   @patch("__builtin__.open")
@@ -1294,15 +1285,15 @@ class TestAmbariServer(TestCase):
   @patch.object(ambari_server, "get_validated_filepath_input")
   @patch.object(ambari_server, "get_validated_string_input")
   def test_import_cert_and_key_with_incorrect_password(self,
-                                                       get_validated_string_input_mock,\
-                                                       get_validated_filepath_input_mock,\
-                                                       os_path_join_mock,\
-                                                       run_os_command_mock,\
-                                                       import_file_to_keystore_mock,\
-                                                       set_file_permissions_mock,\
-                                                       read_ambari_user_mock,\
-                                                       is_root_mock,\
-                                                       copy_file_mock,\
+                                                       get_validated_string_input_mock, \
+                                                       get_validated_filepath_input_mock, \
+                                                       os_path_join_mock, \
+                                                       run_os_command_mock, \
+                                                       import_file_to_keystore_mock, \
+                                                       set_file_permissions_mock, \
+                                                       read_ambari_user_mock, \
+                                                       is_root_mock, \
+                                                       copy_file_mock, \
                                                        open_mock):
     get_validated_string_input_mock.return_value = "incorrect_password"
     get_validated_filepath_input_mock.return_value = 'filename'
@@ -1313,92 +1304,92 @@ class TestAmbariServer(TestCase):
 
 
     #provided password doesn't match, openssl command returns an error
-    run_os_command_mock.return_value = (1, "",	"Some error message")
+    run_os_command_mock.return_value = (1, "", "Some error message")
 
     self.assertFalse(ambari_server.import_cert_and_key_action(*["key_dir", None]))
     self.assertFalse(ambari_server.import_cert_and_key("key_dir"))
 
   def test_is_valid_cert_exp(self):
-    
+
     #No data in certInfo
     certInfo = {}
     is_valid = ambari_server.is_valid_cert_exp(certInfo)
     self.assertFalse(is_valid)
-    
+
     #Issued in future
     issuedOn = (datetime.datetime.now() + datetime.timedelta(hours=1000)).strftime(ambari_server.SSL_DATE_FORMAT)
     expiresOn = (datetime.datetime.now() + datetime.timedelta(hours=2000)).strftime(ambari_server.SSL_DATE_FORMAT)
-    certInfo = {ambari_server.NOT_BEFORE_ATTR : issuedOn,
-                ambari_server.NOT_AFTER_ATTR  : expiresOn}
+    certInfo = {ambari_server.NOT_BEFORE_ATTR: issuedOn,
+                ambari_server.NOT_AFTER_ATTR: expiresOn}
     is_valid = ambari_server.is_valid_cert_exp(certInfo)
     self.assertFalse(is_valid)
-    
+
     #Was expired
     issuedOn = (datetime.datetime.now() - datetime.timedelta(hours=2000)).strftime(ambari_server.SSL_DATE_FORMAT)
     expiresOn = (datetime.datetime.now() - datetime.timedelta(hours=1000)).strftime(ambari_server.SSL_DATE_FORMAT)
-    certInfo = {ambari_server.NOT_BEFORE_ATTR : issuedOn,
-                ambari_server.NOT_AFTER_ATTR  : expiresOn}
+    certInfo = {ambari_server.NOT_BEFORE_ATTR: issuedOn,
+                ambari_server.NOT_AFTER_ATTR: expiresOn}
     is_valid = ambari_server.is_valid_cert_exp(certInfo)
     self.assertFalse(is_valid)
-    
+
     #Valid
     issuedOn = (datetime.datetime.now() - datetime.timedelta(hours=2000)).strftime(ambari_server.SSL_DATE_FORMAT)
     expiresOn = (datetime.datetime.now() + datetime.timedelta(hours=1000)).strftime(ambari_server.SSL_DATE_FORMAT)
-    certInfo = {ambari_server.NOT_BEFORE_ATTR : issuedOn,
-                ambari_server.NOT_AFTER_ATTR  : expiresOn}
+    certInfo = {ambari_server.NOT_BEFORE_ATTR: issuedOn,
+                ambari_server.NOT_AFTER_ATTR: expiresOn}
     is_valid = ambari_server.is_valid_cert_exp(certInfo)
     self.assertTrue(is_valid)
-    
+
   @patch.object(ambari_server, "get_fqdn")
   def test_is_valid_cert_host(self, get_fqdn_mock):
-    
+
     #No data in certInfo
     certInfo = {}
     is_valid = ambari_server.is_valid_cert_host(certInfo)
     self.assertFalse(is_valid)
-    
+
     #Failed to get FQDN
     get_fqdn_mock.return_value = None
     is_valid = ambari_server.is_valid_cert_host(certInfo)
     self.assertFalse(is_valid)
-    
+
     #FQDN and Common name in certificated don't correspond
     get_fqdn_mock.return_value = 'host1'
-    certInfo = {ambari_server.COMMON_NAME_ATTR : 'host2'}
+    certInfo = {ambari_server.COMMON_NAME_ATTR: 'host2'}
     is_valid = ambari_server.is_valid_cert_host(certInfo)
     self.assertFalse(is_valid)
-    
+
     #FQDN and Common name in certificated correspond
     get_fqdn_mock.return_value = 'host1'
-    certInfo = {ambari_server.COMMON_NAME_ATTR : 'host1'}
+    certInfo = {ambari_server.COMMON_NAME_ATTR: 'host1'}
     is_valid = ambari_server.is_valid_cert_host(certInfo)
     self.assertTrue(is_valid)
-    
+
 
   @patch.object(ambari_server, "get_ambari_properties")
   def test_is_valid_https_port(self, get_ambari_properties_mock):
-    
+
     #No ambari.properties
     get_ambari_properties_mock.return_value = -1
     is_valid = ambari_server.is_valid_https_port(1111)
     self.assertEqual(is_valid, False)
-    
+
     #User entered port used by one way auth
     portOneWay = "1111"
     portTwoWay = "2222"
     validPort = "3333"
-    get_ambari_properties_mock.return_value = {ambari_server.SRVR_ONE_WAY_SSL_PORT_PROPERTY : portOneWay,
-                                               ambari_server.SRVR_TWO_WAY_SSL_PORT_PROPERTY : portTwoWay}
+    get_ambari_properties_mock.return_value = {ambari_server.SRVR_ONE_WAY_SSL_PORT_PROPERTY: portOneWay,
+                                               ambari_server.SRVR_TWO_WAY_SSL_PORT_PROPERTY: portTwoWay}
     is_valid = ambari_server.is_valid_https_port(portOneWay)
     self.assertEqual(is_valid, False)
-    
+
     #User entered port used by two way auth
     is_valid = ambari_server.is_valid_https_port(portTwoWay)
     self.assertEqual(is_valid, False)
-    
+
     #User entered valid port
-    get_ambari_properties_mock.return_value = {ambari_server.SRVR_ONE_WAY_SSL_PORT_PROPERTY : portOneWay,
-                                               ambari_server.SRVR_TWO_WAY_SSL_PORT_PROPERTY : portTwoWay}
+    get_ambari_properties_mock.return_value = {ambari_server.SRVR_ONE_WAY_SSL_PORT_PROPERTY: portOneWay,
+                                               ambari_server.SRVR_TWO_WAY_SSL_PORT_PROPERTY: portTwoWay}
     is_valid = ambari_server.is_valid_https_port(validPort)
     self.assertEqual(is_valid, True)
 
@@ -1406,36 +1397,36 @@ class TestAmbariServer(TestCase):
   @patch("urllib2.urlopen")
   @patch.object(ambari_server, "get_ambari_properties")
   def test_get_fqdn(self, get_ambari_properties_mock, url_open_mock, getfqdn_mock):
-    
+
     #No ambari.properties
     get_ambari_properties_mock.return_value = -1
     fqdn = ambari_server.get_fqdn()
     self.assertEqual(fqdn, None)
-    
+
     #Check mbari_server.GET_FQDN_SERVICE_URL property name (AMBARI-2612)
     #property name should be server.fqdn.service.url
     self.assertEqual(ambari_server.GET_FQDN_SERVICE_URL, "server.fqdn.service.url")
-    
+
     #Read FQDN from service
     p = MagicMock()
     p[ambari_server.GET_FQDN_SERVICE_URL] = 'someurl'
     get_ambari_properties_mock.return_value = p
-    
+
     u = MagicMock()
     host = 'host1.domain.com'
     u.read.return_value = host
     url_open_mock.return_value = u
-    
+
     fqdn = ambari_server.get_fqdn()
     self.assertEqual(fqdn, host)
-    
+
     #Failed to read FQDN from service, getting from socket
     u.reset_mock()
     u.side_effect = Exception("Failed to read FQDN from service")
     getfqdn_mock.return_value = host
     fqdn = ambari_server.get_fqdn()
     self.assertEqual(fqdn, host)
-    
+
 
   @patch.object(ambari_server, "run_os_command")
   def test_get_cert_info(self, run_os_command_mock):
@@ -1444,12 +1435,12 @@ class TestAmbariServer(TestCase):
     run_os_command_mock.return_value = -1, None, None
     cert_info = ambari_server.get_cert_info(path)
     self.assertEqual(cert_info, None)
-    
+
     #Empty result of openssl command
     run_os_command_mock.return_value = 0, None, None
     cert_info = ambari_server.get_cert_info(path)
     self.assertEqual(cert_info, None)
-    
+
     #Positive scenario
     notAfter = 'Jul  3 14:12:57 2014 GMT'
     notBefore = 'Jul  3 14:12:57 2013 GMT'
@@ -1460,9 +1451,9 @@ class TestAmbariServer(TestCase):
     attr3_key = 'CN'
     attr3_value = 'host.domain.com'
     subject_pattern = '/{attr1_key}={attr1_value}/{attr2_key}={attr2_value}/{attr3_key}={attr3_value}'
-    subject = subject_pattern.format(attr1_key = attr1_key, attr1_value = attr1_value,
-                                     attr2_key = attr2_key, attr2_value = attr2_value,
-                                     attr3_key = attr3_key, attr3_value = attr3_value)
+    subject = subject_pattern.format(attr1_key=attr1_key, attr1_value=attr1_value,
+                                     attr2_key=attr2_key, attr2_value=attr2_value,
+                                     attr3_key=attr3_key, attr3_value=attr3_value)
     out_pattern = """
 notAfter={notAfter}
 notBefore={notBefore}
@@ -1473,7 +1464,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
 5lqd8XxOGSYoMOf+70BLN2sB
 -----END CERTIFICATE-----
     """
-    out = out_pattern.format(notAfter = notAfter, notBefore = notBefore, subject = subject)
+    out = out_pattern.format(notAfter=notAfter, notBefore=notBefore, subject=subject)
     run_os_command_mock.return_value = 0, out, None
     cert_info = ambari_server.get_cert_info(path)
     self.assertEqual(cert_info['notAfter'], notAfter)
@@ -1483,7 +1474,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     self.assertEqual(cert_info[attr2_key], attr2_value)
     self.assertEqual(cert_info[attr3_key], attr3_value)
 
-      
+
   @patch('__builtin__.raw_input')
   def test_get_validated_string_input(self, raw_input_mock):
     prompt = 'prompt'
@@ -1495,22 +1486,21 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     inputed_value2 = 'val2'
     raw_input_mock.return_value = inputed_value1
     input = ambari_server.get_validated_string_input(prompt, default_value, None,
-                                             description, False, False, validator)
+                                                     description, False, False, validator)
     self.assertTrue(validator.called)
     self.assertEqual(inputed_value1, input)
-    
+
     validator.side_effect = [False, True]
     raw_input_mock.side_effect = [inputed_value1, inputed_value2]
     input = ambari_server.get_validated_string_input(prompt, default_value, None,
-                                             description, False, False, validator)
+                                                     description, False, False, validator)
     self.assertEqual(inputed_value2, input)
-    
-    
+
 
   @patch.object(ambari_server, "run_os_command")
   @patch("__builtin__.open")
   @patch("os.path.exists")
-  def test_is_server_runing(self, os_path_exists_mock, open_mock,\
+  def test_is_server_runing(self, os_path_exists_mock, open_mock, \
                             run_os_command_mock):
     os_path_exists_mock.return_value = True
     f = open_mock.return_value
@@ -1545,10 +1535,10 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     run_os_command_mock.return_value = 1, "", ""
     failed = False
     try:
-        ambari_server.install_jdk(MagicMock())
-        self.fail("Exception was not rised!")
+      ambari_server.install_jdk(MagicMock())
+      self.fail("Exception was not rised!")
     except FatalException:
-        failed = True
+      failed = True
     self.assertTrue(failed)
 
 
@@ -1564,10 +1554,10 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch.object(ambari_server, "get_JAVA_HOME")
   @patch.object(ambari_server, "get_ambari_properties")
   @patch("shutil.copyfile")
-  def test_download_jdk(self, copyfile_mock, get_ambari_properties_mock, get_JAVA_HOME_mock,\
-                        print_info_msg_mock, write_property_mock,\
+  def test_download_jdk(self, copyfile_mock, get_ambari_properties_mock, get_JAVA_HOME_mock, \
+                        print_info_msg_mock, write_property_mock, \
                         run_os_command_mock, get_YN_input_mock, track_jdk_mock,
-                        path_existsMock, path_isfileMock, statMock,\
+                        path_existsMock, path_isfileMock, statMock, \
                         install_jce_manualy_mock):
     args = MagicMock()
     args.java_home = "somewhere"
@@ -1582,7 +1572,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
       # Expected
       self.assertTrue(get_ambari_properties_mock.called)
       pass
-    # Test case: JDK already exists
+      # Test case: JDK already exists
     p = MagicMock()
     get_ambari_properties_mock.return_value = p
     p.__getitem__.return_value = "somewhere"
@@ -1606,7 +1596,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     except FatalException:
       # Expected
       pass
-    # Test case: JDK file does not exist, os command (curl) result does not
+      # Test case: JDK file does not exist, os command (curl) result does not
     # contain Content-Length
     p.__getitem__.return_value = "somewhere"
     p.__getitem__.side_effect = None
@@ -1618,12 +1608,12 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     except FatalException:
       # Expected
       pass
-    # Successful JDK download
+      # Successful JDK download
     ambari_server.JDK_INSTALL_DIR = os.getcwd()
     get_YN_input_mock.return_value = True
     run_os_command_mock.return_value = (0, "Creating jdk-1.2/jre"
                                            "Content-Length: 32000\r\n"
-                                           , None)
+                                        , None)
     statResult = MagicMock()
     statResult.st_size = 32000
     statMock.return_value = statResult
@@ -1644,8 +1634,10 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     p.__getitem__.side_effect = None
     args.jdk_location = "/existing/jdk/file"
     path_existsMock.side_effect = [False, False, True, False, False, False]
+
     def copyfile_side_effect(s, d):
-       raise Exception("TerribleException")
+      raise Exception("TerribleException")
+
     copyfile_mock.side_effect = copyfile_side_effect
     try:
       ambari_server.download_jdk(args)
@@ -1707,7 +1699,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     self.assertEqual(4, rcode)
 
 
-
   @patch("platform.linux_distribution")
   @patch("platform.system")
   @patch.object(ambari_server, "print_info_msg")
@@ -1740,7 +1731,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     self.assertTrue(write_property_mock.called)
 
 
-
   @patch("__builtin__.open")
   @patch.object(ambari_server, "Properties")
   @patch.object(ambari_server, "search_file")
@@ -1775,9 +1765,11 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   def test_prompt_db_properties_oracle_sname(self, gyni_mock, gvsi_mock, rp_mock, smk_mock):
     ambari_server.PROMPT_DATABASE_OPTIONS = True
     gyni_mock.return_value = True
-    list_of_return_values= ["ambari-server", "ambari", "1", "1521", "localhost", "2"]
+    list_of_return_values = ["ambari-server", "ambari", "1", "1521", "localhost", "2"]
+
     def side_effect(*args, **kwargs):
       return list_of_return_values.pop()
+
     gvsi_mock.side_effect = side_effect
     rp_mock.return_value = "password"
     smk_mock.return_value = (None, False, True)
@@ -1799,9 +1791,11 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   def test_prompt_db_properties_oracle_sid(self, gyni_mock, gvsi_mock, rp_mock, smk_mock):
     ambari_server.PROMPT_DATABASE_OPTIONS = True
     gyni_mock.return_value = True
-    list_of_return_values= ["ambari-server", "ambari", "2", "1521", "localhost", "2"]
+    list_of_return_values = ["ambari-server", "ambari", "2", "1521", "localhost", "2"]
+
     def side_effect(*args, **kwargs):
       return list_of_return_values.pop()
+
     gvsi_mock.side_effect = side_effect
     rp_mock.return_value = "password"
     smk_mock.return_value = (None, False, True)
@@ -1823,9 +1817,11 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   def test_prompt_db_properties_postgre_adv(self, gyni_mock, gvsi_mock, rp_mock, smk_mock):
     ambari_server.PROMPT_DATABASE_OPTIONS = True
     gyni_mock.return_value = True
-    list_of_return_values= ["ambari-server", "ambari", "1"]
+    list_of_return_values = ["ambari-server", "ambari", "1"]
+
     def side_effect(*args, **kwargs):
       return list_of_return_values.pop()
+
     gvsi_mock.side_effect = side_effect
     rp_mock.return_value = "password"
     smk_mock.return_value = (None, False, True)
@@ -1878,7 +1874,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   def test_setup(self, is_root_mock, store_local_properties_mock, is_local_database_mock, store_remote_properties_mock,
                  setup_remote_db_mock, check_selinux_mock, check_jdbc_drivers_mock, check_ambari_user_mock,
                  check_iptables_mock, check_postgre_up_mock, setup_db_mock, configure_postgres_mock,
-                 download_jdk_mock, configure_os_settings_mock,get_YN_input,
+                 download_jdk_mock, configure_os_settings_mock, get_YN_input,
                  verify_setup_allowed_method, is_jdbc_user_changed_mock, remove_file_mock, exists_mock):
     args = MagicMock()
     failed = False
@@ -1982,7 +1978,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
       self.assertTrue("cli was not found" in fe.reason)
 
 
-
   @patch.object(ambari_server, "get_YN_input")
   @patch.object(ambari_server, "setup_db")
   @patch.object(ambari_server, "print_info_msg")
@@ -1992,7 +1987,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch.object(ambari_server, "execute_remote_script")
   @patch.object(ambari_server, "is_root")
   @patch.object(ambari_server, "check_database_name_property")
-  def test_reset(self, check_database_name_property_mock, is_root_mock, execute_remote_script_mock, parse_properties_file_mock, configure_database_username_password_mock,
+  def test_reset(self, check_database_name_property_mock, is_root_mock, execute_remote_script_mock,
+                 parse_properties_file_mock, configure_database_username_password_mock,
                  run_os_command_mock, print_info_msg_mock,
                  setup_db_mock, get_YN_inputMock):
 
@@ -2033,10 +2029,10 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     run_os_command_mock.return_value = (0, None, None)
     ambari_server.reset(args)
     self.assertTrue(setup_db_mock.called)
-    
+
     #remote db case
     args.persistence_type = "remote"
-    execute_remote_script_mock.return_value=(0, None, None)
+    execute_remote_script_mock.return_value = (0, None, None)
     rcode = ambari_server.reset(args)
     self.assertEqual(None, rcode)
     self.assertTrue(execute_remote_script_mock.called)
@@ -2049,8 +2045,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch.object(ambari_server, "is_root")
   @patch.object(ambari_server, "check_database_name_property")
   def test_silent_reset(self, check_database_name_property_mock, is_root_mock, parse_properties_file_mock,
-                 run_os_command_mock, print_info_msg_mock,
-                 setup_db_mock):
+                        run_os_command_mock, print_info_msg_mock,
+                        setup_db_mock):
     is_root_mock.return_value = True
 
     args = MagicMock()
@@ -2059,7 +2055,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     run_os_command_mock.return_value = (0, None, None)
 
     def signal_handler(signum, frame):
-       self.fail("Timed out!")
+      self.fail("Timed out!")
 
     signal.signal(signal.SIGALRM, signal_handler)
     signal.alarm(5)
@@ -2172,7 +2168,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     is_root_mock.return_value = True
 
     # Remote DB
-    args.persistence_type="remote"
+    args.persistence_type = "remote"
     check_iptables_mock.return_value = (0, None)
     try:
       ambari_server.start(args)
@@ -2187,7 +2183,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     parse_properties_file_mock.reset_mock()
 
     # Local DB
-    args.persistence_type="local"
+    args.persistence_type = "local"
 
     # case: postgres failed to start
     check_postgre_up_mock.return_value = 1
@@ -2244,7 +2240,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     parse_properties_file_mock.reset_mock()
 
     # Local DB
-    args.persistence_type="local"
+    args.persistence_type = "local"
 
     ambari_server.start(args)
 
@@ -2253,7 +2249,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     parse_properties_file_mock.reset_mock()
 
     # Remote DB
-    args.persistence_type="remote"
+    args.persistence_type = "remote"
 
     ambari_server.start(args)
 
@@ -2286,9 +2282,9 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
 
     # Check environ master key is set
     popenMock.reset_mock()
-    os_environ_mock.copy.return_value = {"a" : "b",
-        ambari_server.SECURITY_KEY_ENV_VAR_NAME : "masterkey"}
-    args.persistence_type="local"
+    os_environ_mock.copy.return_value = {"a": "b",
+                                         ambari_server.SECURITY_KEY_ENV_VAR_NAME: "masterkey"}
+    args.persistence_type = "local"
     read_ambari_user_mock.return_value = "root"
     is_root_mock.return_value = True
 
@@ -2305,8 +2301,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     popenMock.reset_mock()
     os_environ_mock.reset_mock()
     p.get_property.return_value = 'True'
-    os_environ_mock.copy.return_value = {"a" : "b"}
-    args.persistence_type="local"
+    os_environ_mock.copy.return_value = {"a": "b"}
+    args.persistence_type = "local"
     read_ambari_user_mock.return_value = "root"
     is_root_mock.return_value = True
     get_validated_string_input_method.return_value = "masterkey"
@@ -2350,7 +2346,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
                          configure_postgres_username_password_mock):
     args = MagicMock()
 
-     # Testing call under non-root
+    # Testing call under non-root
     is_root_mock.return_value = False
     try:
       ambari_server.upgrade_stack(args, 'HDP-2.0')
@@ -2380,7 +2376,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch.object(ambari_server, "parse_properties_file")
   @patch.object(ambari_server, "is_root")
   @patch.object(ambari_server, "get_ambari_properties")
-  def test_upgrade(self, get_ambari_properties_mock, is_root_mock, parse_properties_file_mock, update_ambari_properties_mock,
+  def test_upgrade(self, get_ambari_properties_mock, is_root_mock, parse_properties_file_mock,
+                   update_ambari_properties_mock,
                    check_postgre_up_mock, execute_db_script_mock,
                    check_db_consistency_mock, read_ambari_user_mock,
                    print_warning_msg_mock, adjust_directory_permissions_mock):
@@ -2388,9 +2385,9 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     args = MagicMock()
     check_database_name_property_mock = MagicMock()
 
-    args.upgrade_script_file = "/var/lib/"\
-      "ambari-server/resources/upgrade/ddl/"\
-      "Ambari-DDL-Postgres-UPGRADE-1.3.0.sql"
+    args.upgrade_script_file = "/var/lib/" \
+                               "ambari-server/resources/upgrade/ddl/" \
+                               "Ambari-DDL-Postgres-UPGRADE-1.3.0.sql"
     update_ambari_properties_mock.return_value = 0
     check_postgre_up_mock.return_value = 0
     execute_db_script_mock.return_value = 0
@@ -2424,6 +2421,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     # Test if check_database_name_property raise exception
     def effect():
       raise FatalException()
+
     check_database_name_property_mock.side_effect = effect
     ambari_server.upgrade(args)
     self.assertTrue(get_ambari_properties_mock.called)
@@ -2439,7 +2437,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     sys.stdout = sys.__stdout__
 
 
-
   def test_print_error_msg(self):
 
     out = StringIO.StringIO()
@@ -2452,7 +2449,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     sys.stdout = sys.__stdout__
 
 
-
   def test_print_warning_msg(self):
 
     out = StringIO.StringIO()
@@ -2465,7 +2461,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     sys.stdout = sys.__stdout__
 
 
-
   @patch.object(ambari_server, "get_choice_string_input")
   def test_get_YN_input(self, get_choice_string_input_mock):
 
@@ -2474,7 +2469,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     self.assertEqual(4, len(get_choice_string_input_mock.call_args_list[0][0]))
 
 
-
   def test_load_default_db_properties(self):
     args = MagicMock()
 
@@ -2488,14 +2482,14 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     self.assertEquals(args.database_password, "bigdata")
 
     args = MagicMock()
-    ambari_server.DATABASE_INDEX=1
+    ambari_server.DATABASE_INDEX = 1
     ambari_server.load_default_db_properties(args)
     self.assertEquals(args.database, "oracle")
     self.assertEquals(args.database_port, "1521")
 
     failed = False
     args = MagicMock()
-    ambari_server.DATABASE_INDEX=2
+    ambari_server.DATABASE_INDEX = 2
     try:
       ambari_server.load_default_db_properties(args)
     except:
@@ -2514,14 +2508,12 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     failed = False
     sys.argv = list(base_args)
 
-
     try:
       ambari_server.main()
     except SystemExit:
       failed = True
       pass
 
-
     self.assertFalse(failed)
     self.assertTrue(setup_mock.called)
 
@@ -2595,7 +2587,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     pass
 
 
-
   @patch.object(ambari_server, "load_default_db_properties")
   @patch.object(ambari_server, "get_YN_input")
   @patch.object(ambari_server, "get_validated_string_input")
@@ -2609,7 +2600,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     ambari_server.PROMPT_DATABASE_OPTIONS = False
     ambari_server.prompt_db_properties(args)
 
-
     self.assertFalse(load_default_db_properties_mock.called)
     self.assertFalse(get_validated_string_input_mock.called)
     self.assertFalse(get_YN_input_mock.called)
@@ -2650,7 +2640,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     get_YN_input_mock.reset_mock()
 
 
-
   pass
 
   @patch.object(ambari_server, "get_db_cli_tool")
@@ -2661,8 +2650,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
 
 
     #success
-    run_in_shell_mock.return_value=(0, None, None)
-    get_db_cli_tool_mock.return_value="tool"
+    run_in_shell_mock.return_value = (0, None, None)
+    get_db_cli_tool_mock.return_value = "tool"
     args.database = "postgres"
     args.database_password = "some_password"
 
@@ -2684,7 +2673,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     #fail execute
     errcode = 1
     get_db_cli_tool_mock.return_value = "tool"
-    run_in_shell_mock.return_value=(errcode, None, None)
+    run_in_shell_mock.return_value = (errcode, None, None)
     get_db_cli_tool_mock.called = False
     run_in_shell_mock.called = False
 
@@ -2695,7 +2684,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
 
     #fail wrong database - case should be completely impossible
     get_db_cli_tool_mock.return_value = "tool"
-    run_in_shell_mock.return_value=(0, None, None)
+    run_in_shell_mock.return_value = (0, None, None)
     get_db_cli_tool_mock.called = False
     run_in_shell_mock.called = False
     args.database = "unknown"
@@ -2710,11 +2699,11 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   def test_update_ambari_properties(self, get_conf_dir_mock):
 
     properties = ["server.jdbc.user.name=ambari-server\n",
-      "server.jdbc.user.passwd=/etc/ambari-server/conf/password.dat\n",
-      "java.home=/usr/jdk64/jdk1.6.0_31\n",
-      "server.os_type=redhat6\n",
-      "ambari-server.user=ambari\n",
-      "agent.fqdn.service.url=URL\n"]
+                  "server.jdbc.user.passwd=/etc/ambari-server/conf/password.dat\n",
+                  "java.home=/usr/jdk64/jdk1.6.0_31\n",
+                  "server.os_type=redhat6\n",
+                  "ambari-server.user=ambari\n",
+                  "agent.fqdn.service.url=URL\n"]
 
     NEW_PROPERTY = 'some_new_property=some_value\n'
     CHANGED_VALUE_PROPERTY = 'server.os_type=should_not_overwrite_value\n'
@@ -2749,14 +2738,13 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
 
     for line in properties:
       if (line == "agent.fqdn.service.url=URL\n"):
-        if (not ambari_server.GET_FQDN_SERVICE_URL+"=URL\n" in ambari_properties_content) and (line in ambari_properties_content):
+        if (not ambari_server.GET_FQDN_SERVICE_URL + "=URL\n" in ambari_properties_content) and (
+          line in ambari_properties_content):
           self.fail()
       else:
         if not line in ambari_properties_content:
           self.fail()
 
-
-
     if not NEW_PROPERTY in ambari_properties_content:
       self.fail()
 
@@ -2821,7 +2809,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     #Call tested method
     ambari_server.update_ambari_properties()
 
-    ambari_properties =  ambari_server.Properties()
+    ambari_properties = ambari_server.Properties()
     ambari_properties.load(open(fn2))
 
     self.assertTrue(ambari_server.NR_USER_PROPERTY in ambari_properties.keys())
@@ -2844,20 +2832,20 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch.object(ambari_server, "download_jdk")
   @patch.object(ambari_server, "configure_os_settings")
   @patch('__builtin__.raw_input')
-  def test_setup_remote_db_wo_client(self,raw_input, configure_os_settings_mock,
-        download_jdk_mock, check_ambari_user_mock, is_root_mock,
-        check_jdbc_drivers_mock, check_iptables_mock, is_local_db_mock,
-        store_remote_properties_mock, get_db_cli_tool_mock, get_YN_input,
-        exit_mock, verify_setup_allowed_method):
+  def test_setup_remote_db_wo_client(self, raw_input, configure_os_settings_mock,
+                                     download_jdk_mock, check_ambari_user_mock, is_root_mock,
+                                     check_jdbc_drivers_mock, check_iptables_mock, is_local_db_mock,
+                                     store_remote_properties_mock, get_db_cli_tool_mock, get_YN_input,
+                                     exit_mock, verify_setup_allowed_method):
     args = MagicMock()
-    raw_input.return_value =""
+    raw_input.return_value = ""
     is_root_mock.return_value = True
     is_local_db_mock.return_value = False
     get_YN_input.return_value = False
     check_iptables_mock.return_value = (0, "other")
     store_remote_properties_mock.return_value = 0
     get_db_cli_tool_mock.return_value = None
-    check_jdbc_drivers_mock.return_value=0
+    check_jdbc_drivers_mock.return_value = 0
     check_ambari_user_mock.return_value = 0
     download_jdk_mock.return_value = 0
     configure_os_settings_mock.return_value = 0
@@ -2882,18 +2870,18 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch.object(ambari_server, "download_jdk")
   @patch.object(ambari_server, "configure_os_settings")
   @patch('__builtin__.raw_input')
-  def test_store_remote_properties(self,raw_input, configure_os_settings_mock,
-        download_jdk_mock, check_ambari_user_mock, is_root_mock,
-        check_jdbc_drivers_mock, check_iptables_mock, is_local_db_mock,
-        get_db_cli_tool_mock, get_YN_input, exit_mock, verify_setup_allowed_method):
+  def test_store_remote_properties(self, raw_input, configure_os_settings_mock,
+                                   download_jdk_mock, check_ambari_user_mock, is_root_mock,
+                                   check_jdbc_drivers_mock, check_iptables_mock, is_local_db_mock,
+                                   get_db_cli_tool_mock, get_YN_input, exit_mock, verify_setup_allowed_method):
 
-    raw_input.return_value =""
+    raw_input.return_value = ""
     is_root_mock.return_value = True
     is_local_db_mock.return_value = False
     get_YN_input.return_value = False
     check_iptables_mock.return_value = (0, "other")
     get_db_cli_tool_mock.return_value = None
-    check_jdbc_drivers_mock.return_value=0
+    check_jdbc_drivers_mock.return_value = 0
     check_ambari_user_mock.return_value = 0
     download_jdk_mock.return_value = 0
     configure_os_settings_mock.return_value = 0
@@ -2944,12 +2932,14 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch.object(ambari_server, "run_os_command")
   @patch.object(ambari_server, "is_root")
   @patch.object(ambari_server, "check_database_name_property")
-  def test_reset_remote_db_wo_client(self, check_database_name_property_mock, is_root_mock, run_os_command_mock, setup_db_mock,
-                                     get_YN_inputMock, print_error_msg_mock, get_db_cli_tool_mock, parse_properties_file_mock):
+  def test_reset_remote_db_wo_client(self, check_database_name_property_mock, is_root_mock, run_os_command_mock,
+                                     setup_db_mock,
+                                     get_YN_inputMock, print_error_msg_mock, get_db_cli_tool_mock,
+                                     parse_properties_file_mock):
     args = MagicMock()
     get_YN_inputMock.return_value = True
     run_os_command_mock.return_value = (0, None, None)
-    args.persistence_type="remote"
+    args.persistence_type = "remote"
     get_db_cli_tool_mock.return_value = None
     is_root_mock.return_value = True
     try:
@@ -2966,12 +2956,12 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     find_properties_file_mock.return_value = None
     rcode = ambari_server.get_ambari_properties()
     self.assertEqual(rcode, -1)
-  
+
     tf1 = tempfile.NamedTemporaryFile()
     find_properties_file_mock.return_value = tf1.name
-    prop_name='name'
-    prop_value='val'
-    
+    prop_name = 'name'
+    prop_value = 'val'
+
     with open(tf1.name, 'w') as fout:
       fout.write(prop_name + '=' + prop_value)
     fout.close()
@@ -2989,7 +2979,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch('__builtin__.raw_input')
   @patch("sys.exit")
   def check_jdbc_drivers(self, exit_mock, raw_input_mock, print_warning_msg, print_error_msg_mock, copy_files_mock,
-                              find_jdbc_driver_mock, get_ambari_properties_mock):
+                         find_jdbc_driver_mock, get_ambari_properties_mock):
 
     out = StringIO.StringIO()
     sys.stdout = out
@@ -3000,7 +2990,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     drivers_list = ['driver_file']
     resources_dir = '/tmp'
 
-    get_ambari_properties_mock.return_value = {ambari_server.RESOURCES_DIR_PROPERTY : resources_dir}
+    get_ambari_properties_mock.return_value = {ambari_server.RESOURCES_DIR_PROPERTY: resources_dir}
     find_jdbc_driver_mock.return_value = drivers_list
 
     args.database = "oracle"
@@ -3049,7 +3039,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     self.assertTrue(exit_mock.called)
     self.assertTrue(print_error_msg_mock.called)
 
-
     sys.stdout = sys.__stdout__
 
 
@@ -3062,8 +3051,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
 
     tf1 = tempfile.NamedTemporaryFile()
     find_properties_file.return_value = tf1.name
-    prop_name='name'
-    prop_value='val'
+    prop_name = 'name'
+    prop_value = 'val'
 
     with open(tf1.name, 'w') as fout:
       fout.write(prop_name + '=' + prop_value)
@@ -3076,47 +3065,46 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
 
     sys.stdout = sys.__stdout__
 
-  
+
   @patch("os.path.exists")
   @patch("os.remove")
-  @patch.object(ambari_server,"print_warning_msg")
+  @patch.object(ambari_server, "print_warning_msg")
   def test_remove_file(self, printWarningMsgMock, removeMock, pathExistsMock):
     def side_effect():
       raise Exception(-1, "Failed to delete!")
-    
+
     removeMock.side_effect = side_effect
     pathExistsMock.return_value = 1
-    
+
     res = ambari_server.remove_file("/someNonExsistantDir/filename")
-    self.assertEquals(res,1)
-    
+    self.assertEquals(res, 1)
+
     removeMock.side_effect = None
     res = ambari_server.remove_file("/someExsistantDir/filename")
     self.assertEquals(res, 0)
-  
+
   @patch("shutil.copyfile")
   def test_copy_file(self, shutilCopyfileMock):
     def side_effect():
       raise Exception(-1, "Failed to copy!")
-    
+
     shutilCopyfileMock.side_effect = side_effect
-    
+
     try:
-      ambari_server.copy_file("/tmp/psswd","/someNonExsistantDir/filename")
+      ambari_server.copy_file("/tmp/psswd", "/someNonExsistantDir/filename")
       self.fail("Exception on file not copied has not been thrown!")
     except FatalException:
       # Expected
       pass
-    
+
     self.assertTrue(shutilCopyfileMock.called)
-    
-    
+
     shutilCopyfileMock.side_effect = None
     try:
-      ambari_server.copy_file("/tmp/psswd","/root/psswd")
+      ambari_server.copy_file("/tmp/psswd", "/root/psswd")
     except FatalException:
-        self.fail("Exception on file copied should not be thrown!")
-        
+      self.fail("Exception on file copied should not be thrown!")
+
     self.assertTrue(shutilCopyfileMock.called)
 
   @patch.object(ambari_server, "get_ambari_properties")
@@ -3132,61 +3120,61 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     sys.stdout = out
 
     args = MagicMock()
-    
+
     # Check positive scenario
     drivers_list = ['driver_file']
     resources_dir = '/tmp'
-    
-    get_ambari_properties_mock.return_value = {ambari_server.RESOURCES_DIR_PROPERTY : resources_dir}
+
+    get_ambari_properties_mock.return_value = {ambari_server.RESOURCES_DIR_PROPERTY: resources_dir}
     find_jdbc_driver_mock.return_value = drivers_list
     copy_files_mock.return_value = 0
-    
+
     args.database = "oracle"
-    
+
     rcode = ambari_server.check_jdbc_drivers(args)
-    
+
     self.assertEqual(0, rcode)
     copy_files_mock.assert_called_with(drivers_list, resources_dir)
-    
+
     get_ambari_properties_mock.reset_mock()
     find_jdbc_driver_mock.reset_mock()
     copy_files_mock.reset_mock()
     print_error_msg_mock.reset_mock()
     print_warning_msg.reset_mock()
     raw_input_mock.reset_mock()
-    
-    
-    
+
+
+
     # Check negative scenarios
     # Silent option, no drivers
     ambari_server.SILENT = True
-    
+
     find_jdbc_driver_mock.return_value = -1
-    
+
     failed = False
-    
+
     try:
       rcode = ambari_server.check_jdbc_drivers(args)
     except FatalException:
       failed = True
-    
+
     self.assertTrue(print_error_msg_mock.called)
     self.assertTrue(failed)
-    
+
     get_ambari_properties_mock.reset_mock()
     find_jdbc_driver_mock.reset_mock()
     copy_files_mock.reset_mock()
     print_error_msg_mock.reset_mock()
     print_warning_msg.reset_mock()
     raw_input_mock.reset_mock()
-    
+
     # Non-Silent option, no drivers
     ambari_server.SILENT = False
-    
+
     find_jdbc_driver_mock.return_value = -1
-    
+
     failed = False
-    
+
     try:
       rcode = ambari_server.check_jdbc_drivers(args)
     except FatalException:
@@ -3194,87 +3182,87 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
 
     self.assertTrue(failed)
     self.assertTrue(print_error_msg_mock.called)
-    
+
     get_ambari_properties_mock.reset_mock()
     find_jdbc_driver_mock.reset_mock()
     copy_files_mock.reset_mock()
     print_error_msg_mock.reset_mock()
     print_warning_msg.reset_mock()
     raw_input_mock.reset_mock()
-    
+
     # Non-Silent option, no drivers at first ask, present drivers after that
-    
+
     find_jdbc_driver_mock.side_effect = [-1, drivers_list]
-    
+
     rcode = ambari_server.check_jdbc_drivers(args)
-    
+
     self.assertEqual(0, rcode)
     copy_files_mock.assert_called_with(drivers_list, resources_dir)
-    
+
     get_ambari_properties_mock.reset_mock()
     find_jdbc_driver_mock.reset_mock()
     copy_files_mock.reset_mock()
     print_error_msg_mock.reset_mock()
     print_warning_msg.reset_mock()
     raw_input_mock.reset_mock()
-    
+
     # Non-Silent option, no drivers at first ask, no drivers after that
     find_jdbc_driver_mock.side_effect = [-1, -1]
-    
+
     failed = False
-    
+
     try:
       rcode = ambari_server.check_jdbc_drivers(args)
     except FatalException:
       failed = True
-    
+
     self.assertTrue(failed)
     self.assertTrue(print_error_msg_mock.called)
-    
+
     get_ambari_properties_mock.reset_mock()
     find_jdbc_driver_mock.reset_mock()
     copy_files_mock.reset_mock()
     print_error_msg_mock.reset_mock()
     print_warning_msg.reset_mock()
     raw_input_mock.reset_mock()
-    
-    
-    
-    
+
+
+
+
     # Failed to copy_files    
-    
+
     find_jdbc_driver_mock.side_effect = [drivers_list]
     try:
       rcode = ambari_server.check_jdbc_drivers(args)
     except FatalException:
       failed = True
-    
+
     self.assertTrue(failed)
-    
+
     sys.stdout = sys.__stdout__
-    
-    
+
+
   @patch.object(ambari_server, "find_properties_file")
   def test_get_ambari_properties(self, find_properties_file_mock):
 
     find_properties_file_mock.return_value = None
     rcode = ambari_server.get_ambari_properties()
     self.assertEqual(rcode, -1)
-  
+
     tf1 = tempfile.NamedTemporaryFile()
     find_properties_file_mock.return_value = tf1.name
-    prop_name='name'
-    prop_value='val'
-    
+    prop_name = 'name'
+    prop_value = 'val'
+
     with open(tf1.name, 'w') as fout:
       fout.write(prop_name + '=' + prop_value)
     fout.close()
 
     properties = ambari_server.get_ambari_properties()
-    
+
     self.assertEqual(properties[prop_name], prop_value)
     self.assertEqual(properties.fileName, os.path.abspath(tf1.name))
-    
+
     sys.stdout = sys.__stdout__
 
   @patch.object(ambari_server, "check_database_name_property")
@@ -3290,10 +3278,9 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     ambari_server.parse_properties_file(args)
     self.assertEquals(args.persistence_type, "local")
 
-
     with open(tf1.name, 'w') as fout:
       fout.write("\n")
-      fout.write(ambari_server.PERSISTENCE_TYPE_PROPERTY+"=remote")
+      fout.write(ambari_server.PERSISTENCE_TYPE_PROPERTY + "=remote")
 
     args = MagicMock()
 
@@ -3305,16 +3292,17 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch.object(ambari_server, 'is_alias_string')
   @patch.object(ambari_server, 'get_ambari_properties')
   def test_configure_database_username_password_masterkey_persisted(self,
-          get_ambari_properties_method, is_alias_string_method,
-          decrypt_password_for_alias_method):
+                                                                    get_ambari_properties_method,
+                                                                    is_alias_string_method,
+                                                                    decrypt_password_for_alias_method):
 
     out = StringIO.StringIO()
     sys.stdout = out
 
     configs = {ambari_server.JDBC_USER_NAME_PROPERTY: "fakeuser",
-        ambari_server.JDBC_PASSWORD_PROPERTY: "${alias=somealias}",
-        ambari_server.JDBC_DATABASE_PROPERTY: "fakedbname",
-        ambari_server.SECURITY_KEY_IS_PERSISTED: "True" }
+               ambari_server.JDBC_PASSWORD_PROPERTY: "${alias=somealias}",
+               ambari_server.JDBC_DATABASE_PROPERTY: "fakedbname",
+               ambari_server.SECURITY_KEY_IS_PERSISTED: "True"}
 
     get_ambari_properties_method.return_value = configs
 
@@ -3369,16 +3357,16 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch.object(ambari_server, 'get_ambari_properties')
   @patch.object(ambari_server, 'is_root')
   def test_setup_master_key_not_persist(self, is_root_method,
-              get_ambari_properties_method, search_file_message,
-              get_YN_input_method, save_master_key_method,
-              update_properties_method, get_master_key_location_method,
-              read_ambari_user_method, read_master_key_method,
-              save_passwd_for_alias_method, remove_password_file_method,
-              get_is_persisted_method, get_is_secure_method, exists_mock):
+                                        get_ambari_properties_method, search_file_message,
+                                        get_YN_input_method, save_master_key_method,
+                                        update_properties_method, get_master_key_location_method,
+                                        read_ambari_user_method, read_master_key_method,
+                                        save_passwd_for_alias_method, remove_password_file_method,
+                                        get_is_persisted_method, get_is_secure_method, exists_mock):
 
     is_root_method.return_value = True
     p = get_ambari_properties_method.return_value
-    p.get_property.side_effect = [ "fakepasswd", "fakepasswd", "fakepasswd", "fakepasswd"]
+    p.get_property.side_effect = ["fakepasswd", "fakepasswd", "fakepasswd", "fakepasswd"]
     read_master_key_method.return_value = "aaa"
     get_YN_input_method.return_value = False
     read_ambari_user_method.return_value = None
@@ -3398,15 +3386,15 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     self.assertEquals(3, save_passwd_for_alias_method.call_count)
     self.assertTrue(remove_password_file_method.called)
 
-    result_expected = {ambari_server.JDBC_PASSWORD_PROPERTY :
-        ambari_server.get_alias_string(ambari_server.JDBC_RCA_PASSWORD_ALIAS),
-        ambari_server.JDBC_RCA_PASSWORD_FILE_PROPERTY:
-        ambari_server.get_alias_string(ambari_server.JDBC_RCA_PASSWORD_ALIAS),
-        ambari_server.LDAP_MGR_PASSWORD_PROPERTY :
-        ambari_server.get_alias_string(ambari_server.LDAP_MGR_PASSWORD_ALIAS),
-        ambari_server.SSL_TRUSTSTORE_PASSWORD_PROPERTY :
-        ambari_server.get_alias_string(ambari_server.SSL_TRUSTSTORE_PASSWORD_ALIAS),
-        ambari_server.SECURITY_IS_ENCRYPTION_ENABLED : 'true'}
+    result_expected = {ambari_server.JDBC_PASSWORD_PROPERTY:
+                         ambari_server.get_alias_string(ambari_server.JDBC_RCA_PASSWORD_ALIAS),
+                       ambari_server.JDBC_RCA_PASSWORD_FILE_PROPERTY:
+                         ambari_server.get_alias_string(ambari_server.JDBC_RCA_PASSWORD_ALIAS),
+                       ambari_server.LDAP_MGR_PASSWORD_PROPERTY:
+                         ambari_server.get_alias_string(ambari_server.LDAP_MGR_PASSWORD_ALIAS),
+                       ambari_server.SSL_TRUSTSTORE_PASSWORD_PROPERTY:
+                         ambari_server.get_alias_string(ambari_server.SSL_TRUSTSTORE_PASSWORD_ALIAS),
+                       ambari_server.SECURITY_IS_ENCRYPTION_ENABLED: 'true'}
 
     sorted_x = sorted(result_expected.iteritems(), key=operator.itemgetter(0))
     sorted_y = sorted(update_properties_method.call_args[0][1].iteritems(),
@@ -3428,16 +3416,16 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch.object(ambari_server, 'get_ambari_properties')
   @patch.object(ambari_server, 'is_root')
   def test_setup_master_key_persist(self, is_root_method,
-              get_ambari_properties_method, search_file_message,
-              get_YN_input_method, save_master_key_method,
-              update_properties_method, get_master_key_location_method,
-              read_ambari_user_method, read_master_key_method,
-              get_is_persisted_method, get_is_secure_method, exists_mock,
-              save_passwd_for_alias_method):
+                                    get_ambari_properties_method, search_file_message,
+                                    get_YN_input_method, save_master_key_method,
+                                    update_properties_method, get_master_key_location_method,
+                                    read_ambari_user_method, read_master_key_method,
+                                    get_is_persisted_method, get_is_secure_method, exists_mock,
+                                    save_passwd_for_alias_method):
 
     is_root_method.return_value = True
     p = get_ambari_properties_method.return_value
-    p.get_property.side_effect = [ "fakepasswd", None, None, None ]
+    p.get_property.side_effect = ["fakepasswd", None, None, None]
     read_master_key_method.return_value = "aaa"
     get_YN_input_method.side_effect = [True, False]
     read_ambari_user_method.return_value = None
@@ -3455,8 +3443,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     self.assertTrue(save_master_key_method.called)
 
     result_expected = {ambari_server.JDBC_PASSWORD_PROPERTY:
-        ambari_server.get_alias_string(ambari_server.JDBC_RCA_PASSWORD_ALIAS),
-        ambari_server.SECURITY_IS_ENCRYPTION_ENABLED: 'true'}
+                         ambari_server.get_alias_string(ambari_server.JDBC_RCA_PASSWORD_ALIAS),
+                       ambari_server.SECURITY_IS_ENCRYPTION_ENABLED: 'true'}
 
     sorted_x = sorted(result_expected.iteritems(), key=operator.itemgetter(0))
     sorted_y = sorted(update_properties_method.call_args[0][1].iteritems(),
@@ -3480,13 +3468,13 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch.object(ambari_server, 'get_ambari_properties')
   @patch.object(ambari_server, 'is_root')
   def test_reset_master_key_persisted(self, is_root_method,
-              get_ambari_properties_method, search_file_message,
-              get_YN_input_method, get_validated_string_input_method,
-              save_master_key_method, update_properties_method,
-              read_passwd_for_alias_method, save_passwd_for_alias_method,
-              Properties_mock, get_master_key_location_method,
-              read_ambari_user_method, exists_mock,
-              remove_password_file_method, read_master_key_method):
+                                      get_ambari_properties_method, search_file_message,
+                                      get_YN_input_method, get_validated_string_input_method,
+                                      save_master_key_method, update_properties_method,
+                                      read_passwd_for_alias_method, save_passwd_for_alias_method,
+                                      Properties_mock, get_master_key_location_method,
+                                      read_ambari_user_method, exists_mock,
+                                      remove_password_file_method, read_master_key_method):
 
     # Testing call under non-root
     is_root_method.return_value = False
@@ -3504,11 +3492,11 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     search_file_message.return_value = "filepath"
     read_ambari_user_method.return_value = None
     p = get_ambari_properties_method.return_value
-    p.get_property.side_effect = [ 'true', '${alias=fakealias}',
-                                   '${alias=fakealias}',
-                                   '${alias=fakealias}', '${alias=fakealias}']
+    p.get_property.side_effect = ['true', '${alias=fakealias}',
+                                  '${alias=fakealias}',
+                                  '${alias=fakealias}', '${alias=fakealias}']
 
-    get_YN_input_method.side_effect = [ True, True ]
+    get_YN_input_method.side_effect = [True, True]
     read_master_key_method.return_value = "aaa"
     read_passwd_for_alias_method.return_value = "fakepassword"
     save_passwd_for_alias_method.return_value = 0
@@ -3525,14 +3513,14 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     self.assertTrue(3, save_passwd_for_alias_method.call_count)
 
     result_expected = {ambari_server.JDBC_PASSWORD_PROPERTY:
-        ambari_server.get_alias_string(ambari_server.JDBC_RCA_PASSWORD_ALIAS),
-        ambari_server.JDBC_RCA_PASSWORD_FILE_PROPERTY:
-        ambari_server.get_alias_string(ambari_server.JDBC_RCA_PASSWORD_ALIAS),
-        ambari_server.LDAP_MGR_PASSWORD_PROPERTY:
-        ambari_server.get_alias_string(ambari_server.LDAP_MGR_PASSWORD_ALIAS),
-        ambari_server.SSL_TRUSTSTORE_PASSWORD_PROPERTY:
-        ambari_server.get_alias_string(ambari_server.SSL_TRUSTSTORE_PASSWORD_ALIAS),
-        ambari_server.SECURITY_IS_ENCRYPTION_ENABLED: 'true'}
+                         ambari_server.get_alias_string(ambari_server.JDBC_RCA_PASSWORD_ALIAS),
+                       ambari_server.JDBC_RCA_PASSWORD_FILE_PROPERTY:
+                         ambari_server.get_alias_string(ambari_server.J

<TRUNCATED>

Mime
View raw message