Write unit tests for a function

Writes unit tests for one function in my testing framework, covering normal, edge and failure cases, after reading the code.

Task: Write unit tests for the function below. Context: The language is [language] and the testing framework is [testing framework]. The function is meant to [intended behavior]. Our tests live in [test folder or naming pattern]. Rules: - Read the function fully first and list the branches you found before writing any test. - Cover normal input, boundary values, invalid input and every error path, at most twelve tests. - Name each test after the behavior it checks, and keep one assertion idea per test. - Do not change the function. If you think it has a bug, say so after the tests and name the test that shows it. - Mock only what touches the network, the clock or the file system, and never use real credentials in test data. Result: One test file in a single code block. Close with one sentence on the behavior you could not test from the code alone. Material: [paste the function and its imports here]

Updated