stage15-api-pricing.py
TEXT FILE520 B · Public source code for developers, search crawlers and AI agents
1def quote(version, units, rate_sat):
2 if not isinstance(version, str) or not version or len(version)>64:
3 raise ValueError("tariff version")
4 if any(type(x) is not int or not 0 < x <= 1000000 for x in (units, rate_sat)):
5 raise ValueError("invalid quantity or rate")
6 return {"tariff": version, "units": units, "total_sat": units * rate_sat}
7
8assert quote("v1", 12, 3)["total_sat"] == 36
9try:
10 quote("v1", True, 3)
11except ValueError:
12 pass
13else:
14 raise AssertionError("boolean accepted")Read-only source · Select a line number to link directly · Raw download above
