def test_should_get_template_by_name_with_options(self): self.mock_ov_client.server_profile_templates.get_by_name.return_value = BASIC_TEMPLATE self.mock_ov_client.server_profile_templates.get_new_profile.return_value = PROFILE self.mock_ov_client.server_profile_templates.get_transformation.return_value = TRANSFORMATION_TEMPLATE self.mock_ansible_module.params = PARAMS_GET_BY_NAME_WITH_OPTIONS ServerProfileTemplateFactsModule().run() self.mock_ov_client.server_profile_templates.get_by_name.assert_called_once_with(name=TEMPLATE_NAME) self.mock_ov_client.server_profile_templates.get_new_profile.assert_called_once_with(id_or_uri=TEMPLATE_URI) self.mock_ov_client.server_profile_templates.get_transformation.assert_called_once_with( id_or_uri=TEMPLATE_URI, server_hardware_type_uri=SERVER_HARDWARE_TYPE_FOR_TRANSFORMATION, enclosure_group_uri=ENCLOSURE_GROUP_FOR_TRANSFORMATION ) self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict( server_profile_templates=[BASIC_TEMPLATE], new_profile=PROFILE, transformation=TRANSFORMATION_TEMPLATE ) )
def test_should_get_all_templates(self): self.mock_ov_client.server_profile_templates.get_all.return_value = TEMPLATES self.mock_ansible_module.params = PARAMS_GET_ALL ServerProfileTemplateFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(server_profile_templates=TEMPLATES))
def test_should_get_all_available_networks(self): self.mock_ov_client.server_profile_templates.get_available_networks.return_value = AVAILABLE_NETWORKS self.mock_ansible_module.params = PARAMS_AVAILABLE_NETWORKS ServerProfileTemplateFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict( server_profile_template_available_networks=AVAILABLE_NETWORKS))
def test_should_return_empty_list_when_template_by_name_returns_null(self): self.mock_ov_client.server_profile_templates.get_by_name.return_value = None self.mock_ansible_module.params = PARAMS_GET_BY_NAME ServerProfileTemplateFactsModule().run() self.mock_ov_client.server_profile_templates.get_by_name.assert_called_once_with( name=TEMPLATE_NAME) self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(server_profile_templates=[]))
def test_should_get_template_by_uri(self): self.mock_ov_client.server_profile_templates.get.return_value = BASIC_TEMPLATE self.mock_ansible_module.params = PARAMS_GET_BY_URI ServerProfileTemplateFactsModule().run() self.mock_ov_client.server_profile_templates.get.assert_called_once_with( '/rest/fake') self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(server_profile_templates=[BASIC_TEMPLATE]))
def test_should_get_template_by_name(self): self.mock_ov_client.server_profile_templates.data = BASIC_TEMPLATE self.mock_ansible_module.params = PARAMS_GET_BY_NAME ServerProfileTemplateFactsModule().run() self.mock_ov_client.server_profile_templates.get_by_name.assert_called_once_with( TEMPLATE_NAME) self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(server_profile_templates=[BASIC_TEMPLATE]))
def test_should_get_template_by_name_with_new_profile(self): self.mock_ov_client.server_profile_templates.get_by_name.return_value = BASIC_TEMPLATE self.mock_ov_client.server_profile_templates.get_new_profile.return_value = PROFILE self.mock_ansible_module.params = PARAMS_GET_BY_NAME_WITH_NEW_PROFILE ServerProfileTemplateFactsModule().run() self.mock_ov_client.server_profile_templates.get_by_name.assert_called_once_with( name=TEMPLATE_NAME) self.mock_ov_client.server_profile_templates.get_new_profile.assert_called_once_with( id_or_uri=TEMPLATE_URI) self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(server_profile_templates=[BASIC_TEMPLATE], new_profile=PROFILE))