def METHOD_NAME(
    self,
    expected_location: str,
    asset_object: Union[Code, Environment],
) -> None:
    component_path = "./tests/test_configs/components/helloworld_component.yml"
    component = load_component(component_path)
    assert component._validate().passed is True, json.dumps(component._to_dict(), indent=2)
    def _check_validation_result(new_asset, should_fail=False) -> None:
        setattr(component, expected_location, new_asset)
        validation_result = component._validate()
        if should_fail:
            assert validation_result.passed is False and expected_location in validation_result.error_messages, (
                f"field {expected_location} with value {str(new_asset)} should be invalid, "
                f"but validation message is {repr(validation_result)}"
            )
        else:
            assert validation_result.passed, (
                f"field {expected_location} with value {str(new_asset)} should be valid, "
                f"but met unexpected error: {repr(validation_result)}"
            )
    # object
    # _check_validation_result(asset_object)
    # versioned
    _check_validation_result("azureml:{}:1".format(asset_object.name))
    # labelled
    _check_validation_result("{}@latest".format(asset_object.name))
    # invalid. default version is allowed for environment
    if expected_location not in ["environment"]:
        _check_validation_result("{}".format(asset_object.name), True)
    if expected_location in ["code"]:
        # non-existent path
        _check_validation_result("/tmp/non-existent-path", True)
        # existent path
        _check_validation_result("../python")