def test_get_source_details_from_module_fails_for_unknown_source_type( create_instance_source_via_image_patch, ): module = get_module(source_type="unknownSourceType") create_instance_source_via_image_patch.return_value = None with pytest.raises(Exception): oci_instance.get_source_details_from_module(module) assert create_instance_source_via_image_patch.call_count == 0
def test_get_source_details_from_module_ignores_image_id_top_level_module_parameter_when_source_details_exists( create_instance_source_via_image_patch, ): module = get_module(set_top_level_image_id=True) create_instance_source_via_image_patch.return_value = InstanceSourceViaImageDetails( image_id=module.params["image_id"]) source_details = oci_instance.get_source_details_from_module(module) assert source_details.image_id == module.params["image_id"] create_instance_source_via_image_patch.assert_called_once_with( module.params["image_id"], boot_volume_size_in_gbs=None)
def test_get_source_details_from_module_use_image_id_top_level_module_parameter_when_source_details_does_not_exist( create_instance_source_via_image_patch, ): module = get_module(set_top_level_image_id=True) del module.params["source_details"] create_instance_source_via_image_patch.return_value = InstanceSourceViaImageDetails( image_id=module.params["image_id"]) source_details = oci_instance.get_source_details_from_module(module) assert source_details.image_id == module.params["image_id"] create_instance_source_via_image_patch.assert_called_once_with( module.params["image_id"])
def test_get_source_details_from_module_when_image_id_is_passed_as_source_details( create_instance_source_via_image_patch, ): module = get_module() create_instance_source_via_image_patch.return_value = InstanceSourceViaImageDetails( image_id=module.params["source_details"]["image_id"]) source_details = oci_instance.get_source_details_from_module(module) assert source_details.image_id == module.params["source_details"][ "image_id"] create_instance_source_via_image_patch.assert_called_once_with( module.params["source_details"]["image_id"], boot_volume_size_in_gbs=None)
def test_get_source_details_from_module_when_image_id_is_passed_as_source_details_with_boot_volume_size( create_instance_source_via_image_patch): custom_boot_volume_size_in_gbs = 100 module = get_module( custom_boot_volume_size_in_gbs=custom_boot_volume_size_in_gbs) create_instance_source_via_image_patch.return_value = InstanceSourceViaImageDetails( image_id=module.params["source_details"]["image_id"], boot_volume_size_in_gbs=module.params["source_details"] ["boot_volume_size_in_gbs"], ) source_details = oci_instance.get_source_details_from_module(module) assert source_details.image_id == module.params["source_details"][ "image_id"] assert (source_details.boot_volume_size_in_gbs == module.params["source_details"]["boot_volume_size_in_gbs"]) create_instance_source_via_image_patch.assert_called_once_with( module.params["source_details"]["image_id"], boot_volume_size_in_gbs=100)