harbor run -t openthoughts/tasktrove-exp-rpt-curriculum-medium-curriculum-medium-0034harbor download openthoughts/tasktrove-exp-rpt-curriculum-medium-curriculum-medium-0034Goal
/app/uproot.py (single file) that provides:
open(url: str, httpsource=None) -> ROOTDirectoryROOTDirectory (defined in the same file)What to implement
File location
/app/uproot.py containing both the ROOTDirectory class and the open() function.ROOTDirectory class
class ROOTDirectory: passopen function
def open(url: str, httpsource=None) -> ROOTDirectoryhttpsource is provided and is a dict, use httpsource.get("auth") as the auth parameter.httpsource is not provided or has no auth, pass auth=None to requests.get.requests.get(url, auth=auth) to fetch the URL.response.raise_for_status() to raise requests.exceptions.HTTPError on HTTP errors.ROOTDirectory.Interaction with tests (how tests will validate behavior)
requests.get and simulate:
auth parameter through to requests.get so the mock can decide the response.raise_for_status(), the error should propagate to the caller.open(URL) and open(URL, httpsource={"auth": AUTH}) should return a ROOTDirectory when the mocked response is 200.open(URL, httpsource={"auth": wrong_auth}) should raise an HTTPError when the mock is configured to do so.Edge cases and input validation (moderate)
url is not a string or is an empty string, raise ValueError("url must be a non-empty string").httpsource is provided and is not a dict, raise ValueError("httpsource must be a dict or None").httpsource contains an "auth" key, ensure it is either a tuple of length 2 (username, password) or None. If it's present but of an invalid type/shape, raise ValueError("auth must be a (username, password) tuple or None").httpsource["auth"] is not None, pass it through to requests.get as-is; tests can mock behavior based on its value.Hints (not a full solution)
Deliverable
Notes