import hashlib,importlib.util,json,math
from pathlib import Path
HERE=Path(__file__).resolve().parent;spec=importlib.util.spec_from_file_location('original_row_oracle',HERE.parent/'oracle-original.py');m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m)
def oracle(source,lane):
    dto=m.oracle(source,lane)
    if lane=='C':
        row=dto['data']['rows'][0]
        for k in ['power','carbohydrate','protein','fat','sodium']:
            if type(row[k]) is float and math.isfinite(row[k]):row[k]=float(format(row[k],'.2f'))
        if type(row['use_weight']) is float:row['use_weight']=float(format(row['use_weight'],'.6g'))
    return m.json_numbers(dto)
if __name__=='__main__':
    for lane in ['B','C']:
        root=HERE/'private'/lane;source=json.loads((root/'before.json').read_text());value=oracle(source,lane);f=root/'expected-before-http.json';assert not f.exists();f.write_text(json.dumps(value,ensure_ascii=False,indent=2)+'\n');f.chmod(0o600);print(json.dumps({'lane':lane,'expected_sha256':hashlib.sha256(f.read_bytes()).hexdigest(),'nutrition_sum':value['data']['nutrition_sum'],'HTTP':0}))
