import json


def derive_cache_values(post_str):
    """
    Extracts parts from the post request to be inserted into or extracted from the import cache.
    This requires parsing the request multiple times during the test, but it should be the
    succinct way to avoid duplicating the post data in test inputs, or breaking it up into even
    more files.
    """
    parsed_json = json.loads(post_str)

    # extract series data first.  everything else is context
    series = parsed_json["series"]

    del parsed_json["series"]
    context = json.dumps(parsed_json)
    series = json.dumps(series)
    return context, series