def METHOD_NAME(cli, datafiles, operation, target, template, expected_stage_order, expected_build_order):
    project = str(datafiles)
    # Configure to only allow one fetcher at a time, make it easy to
    # determine what is being planned in what order.
    cli.configure({"scheduler": {"fetchers": 1, "builders": 1}})
    # Build the project from the template, make import elements
    # all with the same repo
    #
    for element, dependencies in template.items():
        create_element(project, element, dependencies)
    # Run test and collect results
    if operation == "show":
        result = cli.run(args=["show", "--deps", "all", "--format", "%{name}", target], project=project, silent=True)
        result.assert_success()
        results = result.output.splitlines()
    else:
        if operation == "fetch":
            result = cli.run(args=["source", "fetch", "--deps", "all", target], project=project, silent=True)
        else:
            result = cli.run(args=["build", target], project=project, silent=True)
        result.assert_success()
        results = result.get_start_order(operation)
    # When running `bst build`, the elements are depth sorted for optimal processing
    if operation == "build":
        expected = expected_build_order
    else:
        # Otherwise, we get the usual deterministic staging order
        expected = expected_stage_order
    # Assert the order
    print("Expected order: {}".format(expected))
    print("Observed result order: {}".format(results))
    assert results == expected