You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sm...@apache.org on 2013/08/10 02:17:53 UTC
git commit: AMBARI-2863. Unit test failure in ambari-agent due to
missing import. (smohanty)
Updated Branches:
refs/heads/trunk eae96d751 -> 38eea5654
AMBARI-2863. Unit test failure in ambari-agent due to missing import. (smohanty)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/38eea565
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/38eea565
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/38eea565
Branch: refs/heads/trunk
Commit: 38eea56545ae44ac56944bef796cebee1c58f120
Parents: eae96d7
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Fri Aug 9 17:17:32 2013 -0700
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Fri Aug 9 17:17:32 2013 -0700
----------------------------------------------------------------------
ambari-agent/src/main/python/ambari_agent/HostInfo.py | 1 +
ambari-agent/src/test/python/TestHostInfo.py | 4 +++-
ambari-agent/src/test/python/TestRegistration.py | 10 ++++++----
3 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/38eea565/ambari-agent/src/main/python/ambari_agent/HostInfo.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/HostInfo.py b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
index 48aa659..889129a 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostInfo.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
@@ -27,6 +27,7 @@ import time
import subprocess
import threading
import shlex
+import platform
from PackagesAnalyzer import PackagesAnalyzer
from HostCheckReportFileHandler import HostCheckReportFileHandler
from Hardware import Hardware
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/38eea565/ambari-agent/src/test/python/TestHostInfo.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestHostInfo.py b/ambari-agent/src/test/python/TestHostInfo.py
index b45cd18..778b9f3 100644
--- a/ambari-agent/src/test/python/TestHostInfo.py
+++ b/ambari-agent/src/test/python/TestHostInfo.py
@@ -410,14 +410,16 @@ class TestHostInfo(TestCase):
self.assertEquals(result, {})
+ @patch.object(HostInfo, "get_os_type")
@patch("subprocess.Popen")
- def test_checkLiveServices(self, subproc_popen):
+ def test_checkLiveServices(self, subproc_popen, get_os_type_method):
hostInfo = HostInfo()
p = MagicMock()
p.returncode = 0
p.communicate.return_value = ('', 'err')
subproc_popen.return_value = p
result = []
+ get_os_type_method.return_value = 'redhat'
hostInfo.checkLiveServices(['service1'], result)
self.assertEquals(result[0]['status'], 'Healthy')
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/38eea565/ambari-agent/src/test/python/TestRegistration.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestRegistration.py b/ambari-agent/src/test/python/TestRegistration.py
index 18d08ca..af36c97 100644
--- a/ambari-agent/src/test/python/TestRegistration.py
+++ b/ambari-agent/src/test/python/TestRegistration.py
@@ -21,18 +21,20 @@ limitations under the License.
from unittest import TestCase
import os
import tempfile
-
+from mock.mock import patch
+from mock.mock import MagicMock
from ambari_agent.Register import Register
from ambari_agent.AmbariConfig import AmbariConfig
-
+from ambari_agent.HostInfo import HostInfo
class TestRegistration(TestCase):
- def test_registration_build(self):
+ @patch.object(HostInfo, 'get_os_type')
+ def test_registration_build(self, get_os_type_method):
config = AmbariConfig().getConfig()
tmpdir = tempfile.gettempdir()
config.set('agent', 'prefix', tmpdir)
-
+ get_os_type_method.return_value = 'redhat'
ver_file = os.path.join(tmpdir, "version")
with open(ver_file, "w") as text_file:
text_file.write("1.3.0")