Skip to content

test(python): pin what timeseries.create refuses - #166

Merged
olavgg merged 1 commit into
mainfrom
test/timeseries-create-rejections
Sep 29, 2026
Merged

olavgg merged 1 commit into
mainfrom
test/timeseries-create-rejections

Conversation

@JosteinGj

Copy link
Copy Markdown
Contributor

Summary

The "invalid input" tests in test_timeseries_sync.py and test_timeseries_async.py, the ones carrying xfail(reason="TBD what are invalid units"), were inside a """TODO …""" string literal, so pytest never collected them. They could not have run anyway: the indentation was broken, they passed units= for unit, and they never called create. This deletes them and adds test_timeseries_rejections.py, built from probing the api.

Refused in Python, before any request

  • unit=0, unit_external_id=0, external_id=12, name=5, value_type=None, non-string metadata values → TypeError (the binding's fields are typed str)
  • value_type of "", big_int, strings or hex → ValueError

Refused by the api — 400 constraint-violation, with fields naming exactly the offending property

  • unit absent, None, "" or " " → unit: timeseries.unit.not.blank
  • only unit_external_id → same. REST does not fill unit in from the catalogue, unlike the MCP timeseries_create tool.
  • unit of 65 characters (64 is accepted, and the test checks that boundary)
  • unit_external_id of "" or ab (min 3), name of "", ab or 513 characters, external_id of ab
  • several bad fields in one body are all named at once
  • the async client surfaces the same problem

Things the api accepts that the tests do not pin

Worth a look on the platform side, but a product decision rather than something to encode here:

  • an unknown unitExternalId (no_such_unit_xyz) is stored; REST never looks it up
  • a unitExternalId that disagrees with unit (Celsius on pressure_bar) is stored
  • a whitespace-only unitExternalId (" ") passes the size check and is stored as-is
  • the unitExternalId size violation's message is the literal {unit.externalId.size}, an unresolved i18n key

No SDK surface changes, so no docs pages are affected.

Test plan

  • test_timeseries_rejections.py, test_timeseries_sync.py, test_timeseries_async.py against a local backend: 62 passed

🤖 Generated with Claude Code

…draft

The invalid-input tests in test_timeseries_sync.py and _async.py sat
inside a string literal since the Python SDK landed, so pytest never
collected them, and they could not have run as written. They are gone.

test_timeseries_rejections.py covers what is actually refused, and
where. Wrongly typed input (unit=0, a non-string metadata value) is a
TypeError from the constructor and an unknown value_type a ValueError;
neither reaches the api. The api answers the rest with a 400
constraint-violation naming each field: unit absent, None, empty or
blank; a unit_external_id without a unit, which REST does not fill in
from the catalogue the way the MCP tool does; unit over 64 characters;
unit_external_id, name and external_id under their minimum lengths.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: jgjesdal <jostein@intellistream.ai>
@JosteinGj
JosteinGj requested a review from olavgg September 29, 2026 12:39
@olavgg
olavgg merged commit 1b5a00c into main Sep 29, 2026
18 checks passed
@olavgg
olavgg deleted the test/timeseries-create-rejections branch September 29, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants