diff --git a/tests/fixtures/root_folder_parent.yaml b/tests/fixtures/root_folder_parent.yaml new file mode 100644 index 0000000..3f1bc50 --- /dev/null +++ b/tests/fixtures/root_folder_parent.yaml @@ -0,0 +1,294 @@ +interactions: +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + User-Agent: [python-requests/2.3.0 CPython/3.4.1 Darwin/13.3.0] + method: GET + uri: https://vcsa:443//sdk/vimServiceVersions.xml + response: + body: {string: "\n\n\n + \ \n urn:vim25\n 5.5\n \n + \ 5.1\n 5.0\n 4.1\n + \ 4.0\n 2.5u2\n 2.5\n + \ \n \n \n urn:vim2\n + \ 2.0\n \n\n"} + headers: + Connection: [Keep-Alive] + Content-Length: ['530'] + Content-Type: [text/xml] + Date: ['Tue, 12 Aug 2014 19:57:19 GMT'] + status: {code: 200, message: OK} +- request: + body: ' + + + + <_this type="ServiceInstance">ServiceInstance + + ' + headers: + Accept-Encoding: ['gzip, deflate'] + Content-Type: [text/xml; charset=UTF-8] + Cookie: [''] + SOAPAction: ['"urn:vim25/5.5"'] + method: POST + uri: https://vcsa:443/sdk + response: + body: {string: "\n\n\ngroup-d1propertyCollectorViewManagerVMware vCenter + ServerVMware vCenter Server 5.5.0 build-1750787 (Sim)VMware, + Inc.5.5.01750787 (Sim)INTL000linux-x64vpxVirtualCenter5.50CEDF86B-B8A6-484F-9601-F9C5E4F83F45VMware + VirtualCenter Server5.0VpxSettingsUserDirectorySessionManagerAuthorizationManagerServiceMgrPerfMgrScheduledTaskManagerAlarmManagerEventManagerTaskManagerExtensionManagerCustomizationSpecManagerCustomFieldsManagerDiagMgrLicenseManagerSearchIndexFileManagerDatastoreNamespaceManagervirtualDiskManagerSnmpSystemProvCheckerCompatCheckerOvfManagerIpPoolManagerDVSManagerHostProfileManagerClusterProfileManagerMoComplianceManagerLocalizationManagerStorageResourceManagerguestOperationsManager\n\n"} + headers: + Cache-Control: [no-cache] + Connection: [Keep-Alive] + Content-Length: ['3611'] + Content-Type: [text/xml; charset=utf-8] + Date: ['Tue, 12 Aug 2014 19:57:19 GMT'] + Set-Cookie: ['vmware_soap_session="52f9d648-9738-fa0d-722c-989a2a6848ee"; Path=/; + HttpOnly; Secure; '] + status: {code: 200, message: OK} +- request: + body: ' + + + + <_this type="SessionManager">SessionManagermy_usermy_password + + ' + headers: + Accept-Encoding: ['gzip, deflate'] + Content-Type: [text/xml; charset=UTF-8] + Cookie: ['vmware_soap_session="52f9d648-9738-fa0d-722c-989a2a6848ee"; Path=/; + HttpOnly; Secure; '] + SOAPAction: ['"urn:vim25/5.5"'] + method: POST + uri: https://vcsa:443/sdk + response: + body: {string: "\n\n\n52b2e74c-889a-50fa-021d-0ca429bc0730my_usermy_user + 2014-08-12T19:57:19.158827Z2014-08-12T19:57:19.158827Zenenfalse172.16.16.10\n\n"} + headers: + Cache-Control: [no-cache] + Connection: [Keep-Alive] + Content-Length: ['788'] + Content-Type: [text/xml; charset=utf-8] + Date: ['Tue, 12 Aug 2014 19:57:19 GMT'] + status: {code: 200, message: OK} +- request: + body: ' + + + + <_this type="ServiceInstance">ServiceInstance + + ' + headers: + Accept-Encoding: ['gzip, deflate'] + Content-Type: [text/xml; charset=UTF-8] + Cookie: ['vmware_soap_session="52f9d648-9738-fa0d-722c-989a2a6848ee"; Path=/; + HttpOnly; Secure; '] + SOAPAction: ['"urn:vim25/5.5"'] + method: POST + uri: https://vcsa:443/sdk + response: + body: {string: "\n\n\ngroup-d1propertyCollectorViewManagerVMware vCenter + ServerVMware vCenter Server 5.5.0 build-1750787 (Sim)VMware, + Inc.5.5.01750787 (Sim)INTL000linux-x64vpxVirtualCenter5.50CEDF86B-B8A6-484F-9601-F9C5E4F83F45VMware + VirtualCenter Server5.0VpxSettingsUserDirectorySessionManagerAuthorizationManagerServiceMgrPerfMgrScheduledTaskManagerAlarmManagerEventManagerTaskManagerExtensionManagerCustomizationSpecManagerCustomFieldsManagerDiagMgrLicenseManagerSearchIndexFileManagerDatastoreNamespaceManagervirtualDiskManagerSnmpSystemProvCheckerCompatCheckerOvfManagerIpPoolManagerDVSManagerHostProfileManagerClusterProfileManagerMoComplianceManagerLocalizationManagerStorageResourceManagerguestOperationsManager\n\n"} + headers: + Cache-Control: [no-cache] + Connection: [Keep-Alive] + Content-Length: ['3611'] + Content-Type: [text/xml; charset=utf-8] + Date: ['Tue, 12 Aug 2014 19:57:19 GMT'] + status: {code: 200, message: OK} +- request: + body: ' + + + + <_this type="PropertyCollector">propertyCollectorServiceInstancefalsecontentServiceInstancefalse1 + + ' + headers: + Accept-Encoding: ['gzip, deflate'] + Content-Type: [text/xml; charset=UTF-8] + Cookie: ['vmware_soap_session="52f9d648-9738-fa0d-722c-989a2a6848ee"; Path=/; + HttpOnly; Secure; '] + SOAPAction: ['"urn:vim25/5.5"'] + method: POST + uri: https://vcsa:443/sdk + response: + body: {string: "\n\n\nServiceInstancecontentgroup-d1propertyCollectorViewManagerVMware vCenter + ServerVMware vCenter Server 5.5.0 build-1750787 (Sim)VMware, + Inc.5.5.01750787 (Sim)INTL000linux-x64vpxVirtualCenter5.50CEDF86B-B8A6-484F-9601-F9C5E4F83F45VMware + VirtualCenter Server5.0VpxSettingsUserDirectorySessionManagerAuthorizationManagerServiceMgrPerfMgrScheduledTaskManagerAlarmManagerEventManagerTaskManagerExtensionManagerCustomizationSpecManagerCustomFieldsManagerDiagMgrLicenseManagerSearchIndexFileManagerDatastoreNamespaceManagervirtualDiskManagerSnmpSystemProvCheckerCompatCheckerOvfManagerIpPoolManagerDVSManagerHostProfileManagerClusterProfileManagerMoComplianceManagerLocalizationManagerStorageResourceManagerguestOperationsManager\n\n"} + headers: + Cache-Control: [no-cache] + Connection: [Keep-Alive] + Content-Length: ['3751'] + Content-Type: [text/xml; charset=utf-8] + Date: ['Tue, 12 Aug 2014 19:57:19 GMT'] + status: {code: 200, message: OK} +- request: + body: ' + + + + <_this type="PropertyCollector">propertyCollectorFolderfalseparentgroup-d1false1 + + ' + headers: + Accept-Encoding: ['gzip, deflate'] + Content-Type: [text/xml; charset=UTF-8] + Cookie: ['vmware_soap_session="52f9d648-9738-fa0d-722c-989a2a6848ee"; Path=/; + HttpOnly; Secure; '] + SOAPAction: ['"urn:vim25/5.5"'] + method: POST + uri: https://vcsa:443/sdk + response: + body: {string: "\n\n\ngroup-d1\n\n"} + headers: + Cache-Control: [no-cache] + Connection: [Keep-Alive] + Content-Length: ['481'] + Content-Type: [text/xml; charset=utf-8] + Date: ['Tue, 12 Aug 2014 19:57:19 GMT'] + status: {code: 200, message: OK} +- request: + body: ' + + + + <_this type="PropertyCollector">propertyCollectorFolderfalseparentgroup-d1false1 + + ' + headers: + Accept-Encoding: ['gzip, deflate'] + Content-Type: [text/xml; charset=UTF-8] + Cookie: ['vmware_soap_session="52f9d648-9738-fa0d-722c-989a2a6848ee"; Path=/; + HttpOnly; Secure; '] + SOAPAction: ['"urn:vim25/5.5"'] + method: POST + uri: https://vcsa:443/sdk + response: + body: {string: "\n\n\ngroup-d1\n\n"} + headers: + Cache-Control: [no-cache] + Connection: [Keep-Alive] + Content-Length: ['481'] + Content-Type: [text/xml; charset=utf-8] + Date: ['Tue, 12 Aug 2014 19:57:19 GMT'] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/test_managed_object.py b/tests/test_managed_object.py new file mode 100644 index 0000000..39a1559 --- /dev/null +++ b/tests/test_managed_object.py @@ -0,0 +1,35 @@ +# VMware vSphere Python SDK +# Copyright (c) 2008-2014 VMware, Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from __future__ import print_function + +from tests import fixtures_path +import unittest +import vcr + +from pyVim import connect + +class ManagedObjectTests(unittest.TestCase): + + @vcr.use_cassette('root_folder_parent.yaml', + cassette_library_dir=fixtures_path, record_mode='once') + def test_root_folder_parent(self): + # see: http://python3porting.com/noconv.html + si = connect.SmartConnect(host='vcsa', + user='my_user', + pwd='my_password') + root_folder = si.content.rootFolder + self.assertTrue(hasattr(root_folder, 'parent')) + # NOTE (hartsock): assertIsNone does not work in Python 2.6 + self.assertTrue(root_folder.parent is None)