Skip to content

Commit

Permalink
Merge pull request ansible#64 from HewlettPackard/python35_fix
Browse files Browse the repository at this point in the history
Fixes for Python 3.5
  • Loading branch information
balestrinc committed Apr 18, 2017
2 parents ad78b9d + 2d126a8 commit d3f1617
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
7 changes: 4 additions & 3 deletions test/units/module_utils/test_oneview.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

class OneViewModuleBaseSpec(unittest.TestCase):
"""
PreloadedMocksBaseTestCase provides the mocks used in this test case.
OneViewModuleBaseSpec provides the mocks used in this test case.
"""
mock_ov_client_from_json_file = None
mock_ov_client_from_env_vars = None
Expand Down Expand Up @@ -2191,8 +2191,9 @@ def test_merge_when_custom_attributes_are_equals_with_different_order(self):

merged_data = ServerProfileMerger().merge_data(resource, data)

list1 = list.sort(merged_data[SPKeys.OS_DEPLOYMENT][SPKeys.ATTRIBUTES])
list2 = list.sort(deepcopy(self.profile_with_os_deployment)[SPKeys.OS_DEPLOYMENT][SPKeys.ATTRIBUTES])
list1 = sorted(merged_data[SPKeys.OS_DEPLOYMENT][SPKeys.ATTRIBUTES], key=ResourceComparator._str_sorted)
list2 = sorted(deepcopy(self.profile_with_os_deployment)[SPKeys.OS_DEPLOYMENT][SPKeys.ATTRIBUTES],
key=ResourceComparator._str_sorted)

self.assertEqual(list1, list2)

Expand Down
2 changes: 1 addition & 1 deletion test/units/modules/cloud/hpe/hpe_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def configure_mocks(self, test_case, testing_class):
"""
Preload mocked OneViewClient instance and AnsibleModule
Args:
test_case (object): class instance (self) that are inheriting from ModuleContructorTestCase
test_case (object): class instance (self) that are inheriting from OneViewBaseTestCase
testing_class (object): class being tested
"""
self.testing_class = testing_class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import unittest

from oneview_module_loader import OsDeploymentPlanFactsModule
from oneview_module_loader import OsDeploymentPlanFactsModule, ResourceComparator
from hpe_test_utils import FactsParamsTestCase

ERROR_MSG = 'Fake message error'
Expand Down Expand Up @@ -160,22 +160,24 @@ def test_should_get_custom_attributes_with_nic_support(self):

OsDeploymentPlanFactsModule().run()

self.mock_ansible_module.exit_json.assert_called_once_with(
changed=False,
ansible_facts={'os_deployment_plans': [OS_DEPLOYMENT_PLAN_WITH_NIC],
'os_deployment_plan_custom_attributes':
{'os_custom_attributes_for_server_profile':
[
{'name': 'name1', 'value': 'value1'},
{'name': 'name3', 'value': 'value3'},
{'name': 'name1.dhcp', 'value': False},
{'name': 'name1.networkuri', 'value': ''},
{'name': 'name1.connectionid', 'value': ''},
{'name': 'name1.ipv4disable', 'value': False},
{'name': 'name1.constraint', 'value': 'auto'}
]}
}
)
exit_json_args = self.mock_ansible_module.exit_json.call_args[1]
expected_args = dict(changed=False,
ansible_facts={'os_deployment_plans': [OS_DEPLOYMENT_PLAN_WITH_NIC],
'os_deployment_plan_custom_attributes':
{'os_custom_attributes_for_server_profile':
[
{'name': 'name1', 'value': 'value1'},
{'name': 'name3', 'value': 'value3'},
{'name': 'name1.dhcp', 'value': False},
{'name': 'name1.constraint', 'value': 'auto'},
{'name': 'name1.connectionid', 'value': ''},
{'name': 'name1.networkuri', 'value': ''},
{'name': 'name1.ipv4disable', 'value': False}
]}
})

# Using ResourceComparator due to random list ordering of the Python 3
self.assertTrue(ResourceComparator.compare(exit_json_args, expected_args))


if __name__ == '__main__':
Expand Down

0 comments on commit d3f1617

Please sign in to comment.