Bind friendly planning quotes bookings and explicit hotseat consent (by Codex)
This commit is contained in:
1 parent
cbde7b367e
commit
15d2ac0a4d
20 files changed
+422
-22
No files matched your search
@@ -276,6 +276,27 @@ int main() {
|
||||
auto leap=cal;for(auto &[kind,row]:leap.items()){row["meta"]["season"]={{"startDate","2027-07-01"},{"endDate","2028-06-30"}};row["meta"]["date"]="2028-02-29";}
|
||||
leap["calendar"]["data"]["from"]="2027-07-01";leap["calendar"]["data"]["until"]="2028-06-30";leap["calendar"]["data"]["fixtures"]=Json::array();leap["calendar"]["data"]["days"]={{{"date","2028-02-29"},{"seasonDay",243},{"eventKinds",{"national"}},{"fixtureIds",Json::array()}}};
|
||||
require(engine_calendar_projection(leap).at("count")==366&&engine_calendar_projection(leap).at("today")==243,"leap day lost in calendar geometry");
|
||||
|
||||
auto fp=cal;for(auto &[kind,r]:fp.items())r["meta"]["scope"]["allowedCommands"]={"friendly.book","fixture.reschedule"};
|
||||
const auto fm=fp.at("desktop").at("meta");
|
||||
fp["session"]["data"]["activeManagerId"]="manager:99";fp["session"]["data"]["humanOwnership"]={{{"controller","human"},{"teamId","club:6"},{"managerId","manager:99"}}};
|
||||
fp["session"]["data"]["managers"]={{{"id","manager:99"},{"name","Own manager"},{"status","active"},{"control","human"}}};
|
||||
Json ft={{"id","club:7"},{"name","Actual opponent"},{"nationId","nation:de"}};
|
||||
fp["friendly-plan"]={{"messageType","snapshot"},{"meta",fm},{"data",{{"kind","friendly-plan"},{"teamId","club:6"},{"opponents",{{{"team",ft},{"competitionId","league:real"},{"strength",88}}}},{"bookings",Json::array()}}}};
|
||||
auto fq=Json{{"messageType","snapshot"},{"meta",fm},{"data",{{"kind","friendly"},{"home",home},{"away",ft},{"cost",M(123400)},{"payerManagerId","manager:99"},{"opponentHuman",false},{"dates",{{{"date","2026-07-03"},{"withCalendarEvent",false}},{{"date","2026-07-21"},{"withCalendarEvent",true}}}}}}};
|
||||
auto fv=engine_friendly_projection(fp,fq,"club:7",true);require(fv.at("days")==Json::array({2,20})&&fv.at("flagged_days")==Json::array({20}),"friendly date rules guessed or flagged date discarded");
|
||||
require(engine_friendly_plan(fp).at("opponents")[0].at("rank").is_null(),"friendly picker invented standings");
|
||||
require(engine_friendly_command(fp,fq,"club:7",true,"2026-07-03",true,false,"r").at("payload").at("acceptCost")==true,"cost approval missing");
|
||||
rejects([&]{engine_friendly_command(fp,fq,"club:7",true,"2026-07-03",false,false,"r");});
|
||||
rejects([&]{engine_friendly_command(fp,fq,"club:7",true,"2026-07-04",true,false,"r");});
|
||||
rejects([&]{engine_friendly_projection(fp,fq,"club:7",false);});
|
||||
auto foreign_quote=fq;foreign_quote["meta"]["scope"]["managerId"]="foreign";rejects([&]{engine_friendly_projection(fp,foreign_quote,"club:7",true);});
|
||||
auto hp=fp;hp["session"]["data"]["humanOwnership"].push_back({{"controller","human"},{"teamId","club:7"},{"managerId","manager:2"}});hp["session"]["data"]["managers"].push_back({{"id","manager:2"},{"name","Other manager"},{"status","active"},{"control","human"}});
|
||||
auto hq=fq;hq["data"]["home"]=ft;hq["data"]["away"]=home;hq["data"]["payerManagerId"]="manager:2";hq["data"]["opponentHuman"]=true;
|
||||
require(engine_friendly_projection(hp,hq,"club:7",false).at("other_name")=="Other manager","human approver identity lost");
|
||||
rejects([&]{engine_friendly_command(hp,hq,"club:7",false,"2026-07-03",true,false,"r");});
|
||||
require(engine_friendly_command(hp,hq,"club:7",false,"2026-07-03",true,true,"r").at("payload").at("opponentConsent")==true,"explicit hotseat consent lost");
|
||||
auto bad_payer=hq;bad_payer["data"]["payerManagerId"]="manager:99";rejects([&]{engine_friendly_projection(hp,bad_payer,"club:7",false);});
|
||||
std::cout << "engine DTO, exact money, scope and booking tests passed\n";
|
||||
return 0;
|
||||
} catch (const std::exception &e) { std::cerr << e.what() << '\n'; return 1; }
|
||||
|
||||
Reference in new issue
Block a user