Isolate OpenEnv returns-desk sessions
Implement a stateful mock environment with reset, lookup, and submit actions.
Your task
Each record in operations names a session and one op: reset, lookup, or submit. Every session begins from the supplied fixture for one mock order: days since delivery (a nonnegative integer), returnable (booleans for category eligibility), and existing (whether a return exists). A session is created on its first operation. reset restores existing and returns reset. lookup returns returned or open. submit returns rejected without mutation if days exceeds 30, the category is not returnable, or the session already has a return. Otherwise create the return and respond accepted. Return an object with results, one string per operation in the original order.
Expected behavior
A submission or reset in one session changes only that session. Day 30 is eligible and day 31 is ineligible.
Examples
{"days":30,"returnable":true,"existing":false,"operations":[{"session":"a","op":"submit"},{"session":"b","op":"lookup"},{"session":"a","op":"lookup"}]}{"results":["accepted","open","returned"]}{"days":31,"returnable":true,"existing":false,"operations":[{"session":"a","op":"submit"},{"session":"a","op":"lookup"}]}{"results":["rejected","open"]}{"days":30,"returnable":true,"existing":true,"operations":[{"session":"a","op":"submit"},{"session":"a","op":"lookup"}]}{"results":["rejected","returned"]}Before you begin
- Python functions, lists, and dictionaries
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.