def test_launch_or_update_db_system_service_error(
        db_client, check_and_create_resource_patch):
    error_message = 'Internal Server Error'
    module = get_module(dict())
    check_and_create_resource_patch.side_effect = ServiceError(
        499, 'InternalServerError', dict(), error_message)
    try:
        oci_db_system.launch_or_update_db_system(db_client, module)
    except Exception as ex:
        assert error_message in ex.args[0]
def test_launch_or_update_db_system_client_error(
        db_client, check_and_create_resource_patch):
    error_message = 'databse attribute has no value'
    module = get_module(dict())
    check_and_create_resource_patch.side_effect = ClientError(
        Exception(error_message))
    try:
        oci_db_system.launch_or_update_db_system(db_client, module)
    except Exception as ex:
        assert error_message in ex.args[0]
def test_launch_or_update_db_system_update(db_client, update_db_system_patch):
    module = get_module(dict({'db_system_id': 'ocid1.dbsystem.aaa'}))
    db_system = get_db_system()
    update_db_system_patch.return_value = {
        'db_system': to_dict(db_system),
        'changed': True
    }
    result = oci_db_system.launch_or_update_db_system(db_client, module)
    assert result['db_system']['display_name'] is db_system.display_name
def test_launch_or_update_db_system_update(db_client, update_db_system_patch):
    module = get_module(dict({"db_system_id": "ocid1.dbsystem.aaa"}))
    db_system = get_db_system()
    update_db_system_patch.return_value = {
        "db_system": to_dict(db_system),
        "changed": True,
    }
    result = oci_db_system.launch_or_update_db_system(db_client, module)
    assert result["db_system"]["display_name"] is db_system.display_name
def test_launch_or_update_db_system_launch(db_client,
                                           check_and_create_resource_patch):
    module = get_module(dict())
    db_system = get_db_system()
    check_and_create_resource_patch.return_value = {
        'db_system': to_dict(db_system),
        'changed': True
    }
    result = oci_db_system.launch_or_update_db_system(db_client, module)
    assert result['db_system']['display_name'] is db_system.display_name
def test_launch_or_update_db_system_launch(db_client,
                                           check_and_create_resource_patch):
    module = get_module(dict())
    db_system = get_db_system()
    check_and_create_resource_patch.return_value = {
        "db_system": to_dict(db_system),
        "changed": True,
    }
    result = oci_db_system.launch_or_update_db_system(db_client, module)
    assert result["db_system"]["display_name"] is db_system.display_name