Repository: ambari
Updated Branches:
  refs/heads/trunk 664a626e2 -> d05842878


AMBARI-13226. Second ambari-server silent-mode setup does not switch DB - add 
unit tests.(vbrodetskyi)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d0584287
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d0584287
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d0584287

Branch: refs/heads/trunk
Commit: d058428782391ac2e6524f3e7b35a9f4a69c1c9d
Parents: 664a626
Author: Vitaly Brodetskyi <[email protected]>
Authored: Thu Sep 24 17:25:30 2015 +0300
Committer: Vitaly Brodetskyi <[email protected]>
Committed: Thu Sep 24 17:25:30 2015 +0300

----------------------------------------------------------------------
 .../src/test/python/TestAmbariServer.py         | 34 ++++++++++++++++++++
 1 file changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d0584287/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 3dcf02a..d4a1450 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -425,6 +425,40 @@ class TestAmbariServer(TestCase):
 
   @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = 
os_distro_value))
   @patch.object(_ambari_server_, "setup")
+  @patch("optparse.OptionParser")
+  def test_main_with_preset_dbms(self, optionParserMock, setup_method):
+    opm = optionParserMock.return_value
+    options = MagicMock()
+    args = ["setup"]
+    opm.parse_args.return_value = (options, args)
+
+    options.dbms = "sqlanywhere"
+    options.sid_or_sname = "sname"
+    _ambari_server_.mainBody()
+
+    self.assertTrue(setup_method.called)
+    self.assertEquals(options.database_index, 5)
+    pass
+
+  @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = 
os_distro_value))
+  @patch.object(_ambari_server_, "setup")
+  @patch.object(_ambari_server_, "fix_database_options")
+  @patch("optparse.OptionParser")
+  def test_fix_database_options_called(self, optionParserMock, 
fixDBOptionsMock, setup_method):
+    opm = optionParserMock.return_value
+    options = MagicMock()
+    args = ["setup"]
+    opm.parse_args.return_value = (options, args)
+
+    _ambari_server_.mainBody()
+
+    self.assertTrue(setup_method.called)
+    self.assertTrue(fixDBOptionsMock.called)
+    set_silent(False)
+    pass
+
+  @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = 
os_distro_value))
+  @patch.object(_ambari_server_, "setup")
   @patch.object(_ambari_server_, "start")
   @patch.object(_ambari_server_, "stop")
   @patch.object(_ambari_server_, "reset")

Reply via email to