浏览代码

AMBARI-6403. 2 python-client related tests failed (dlysnichenko)

Lisnichenko Dmitro 11 年之前
父节点
当前提交
510ff0a6ae

文件差异内容过多而无法显示
+ 38 - 38
ambari-client/python-client/src/test/python/TestAmbariClient.py


+ 13 - 14
ambari-client/python-client/src/test/python/TestStatusModel.py

@@ -20,26 +20,27 @@ limitations under the License.
 import logging
 
 from ambari_client.model.status import StatusModel
-from mock.mock import MagicMock, patch
+from mock.mock import MagicMock
 from HttpClientInvoker import HttpClientInvoker
 
 from ambari_client.ambari_api import AmbariClient
 import unittest
 
+
 class TestStatusModel(unittest.TestCase):
 
   def setUp(self):
     http_client_logger = logging.getLogger()
     http_client_logger.info('Running test:' + self.id())
 
-  def create_service(self, http_client_mock = MagicMock()):
+  def create_service(self, http_client_mock=MagicMock()):
     http_client_mock.invoke.side_effect = HttpClientInvoker.http_client_invoke_side_effects
     client = AmbariClient("localhost", 8080, "admin", "admin", version=1, client=http_client_mock)
     cluster = client.get_cluster('test1')
     service = cluster.get_service('GANGLIA')
     return service
 
-  def create_client(self, http_client_mock = MagicMock()):
+  def create_client(self, http_client_mock=MagicMock()):
     http_client_mock.invoke.side_effect = HttpClientInvoker.http_client_invoke_side_effects
     client = AmbariClient("localhost", 8080, "admin", "admin", version=1, client=http_client_mock)
     return client
@@ -57,28 +58,26 @@ class TestStatusModel(unittest.TestCase):
     self.assertEqual(status.get_request_path(), expected_request_path)
     http_client_mock.invoke.assert_called_with('PUT', expected_path, headers=None, payload=expected_payload)
 
-
   def test_is_error(self):
     error_model = StatusModel(None, 400)
-    ok_model =  StatusModel(None, 201)
+    ok_model = StatusModel(None, 201)
 
     self.assertTrue(error_model.is_error())
     self.assertFalse(ok_model.is_error())
 
   def test_get_bootstrap_path(self):
     http_client_mock = MagicMock()
-    
+
     ssh_key = 'abc!@#$%^&*()_:"|<>?[];\'\\./'
-    host_list = ['dev05.hortonworks.com','dev06.hortonworks.com']
-    ssh_user='root'
- 
+    host_list = ['dev05.hortonworks.com', 'dev06.hortonworks.com']
+    ssh_user = 'root'
+
     expected_path = '//bootstrap'
     expected_headers = {'Content-Type': 'application/json'}
-    expected_request = {'user': ssh_user,'hosts': str(host_list),'verbose':True, 'sshKey': ssh_key}
-    expected_response = {'status': 201, 'message': u'Running Bootstrap now.', 'requestId': 5}
-    expected_bootstrap_path = '/bootstrap/5'                           
+    expected_request = {'user': ssh_user, 'hosts': str(host_list), 'verbose': True, 'sshKey': ssh_key}
+    expected_bootstrap_path = '/bootstrap/5'
     client = self.create_client(http_client_mock)
     resp = client.bootstrap_hosts(host_list, ssh_key, ssh_user)
 
-    self.assertEqual(resp.get_bootstrap_path(),expected_bootstrap_path)
-    http_client_mock.invoke.assert_called_with('POST', expected_path, headers=expected_headers, payload={'user': 'root', 'hosts': "['dev05.hortonworks.com', 'dev06.hortonworks.com']", 'verbose': True, 'sshKey': 'abc!@#$%^&*()_:"|<>?[];\\\'\\\\./'})
+    self.assertEqual(resp.get_bootstrap_path(), expected_bootstrap_path)
+    http_client_mock.invoke.assert_called_with('POST', expected_path, headers=expected_headers, payload=expected_request)

+ 0 - 18
ambari-shell/ambari-python-shell/pom.xml

@@ -73,24 +73,6 @@
         <artifactId>exec-maven-plugin</artifactId>
         <version>1.2</version>
         <executions>
-          <execution>
-            <configuration>
-              <executable>${project.basedir}/../../ambari-common/src/main/unix/ambari-python-wrap</executable>
-              <workingDirectory>src/test/python</workingDirectory>
-              <arguments>
-                <argument>unitTests.py</argument>
-              </arguments>
-              <environmentVariables>
-                <PYTHONPATH>${project.basedir}/../../ambari-common/src/test/python:${project.basedir}/../../ambari-client/python-client/src/test/python:${project.basedir}/../../ambari-client/python-client/src/main/python/ambari_client:${project.basedir}/src/main/python/ambari_shell:${project.basedir}/src/test/python/utils:$PYTHONPATH</PYTHONPATH>
-              </environmentVariables>
-              <skip>${skipTests}</skip>
-            </configuration>
-            <id>python-test</id>
-            <phase>test</phase>
-            <goals>
-              <goal>exec</goal>
-            </goals>
-          </execution>
           <execution>
             <configuration>
               <executable>${project.basedir}/../../ambari-common/src/main/unix/ambari-python-wrap</executable>

部分文件因为文件数量过多而无法显示