diff options
| author | Pjotr Prins <pjotr.public01@thebird.nl> | 2026-10-03 14:01:01 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-10-03 14:01:01 +0000 |
| commit | 19640851a4c26e2398781c1713b908ac711b2db5 (patch) | |
| tree | 34df9ae40916f9f512ec7d724910106eb67bebb4 /test/python | |
| parent | 7c1bdb98a569d8b6389b222af746155c53aa3761 (diff) | |
| download | genenetwork4-19640851a4c26e2398781c1713b908ac711b2db5.tar.gz | |
Match group by numeric Id, use Group alias for InbredSet fields.
* src/db.rs (get_group_by_name): Also match CAST(Id AS CHAR), so a
numeric Id works like GeneNetwork2's wqflask.api.router.get_group_info
plus gn-guile's gn.data.population:population-info, which looks a
group up by Id only.
(GroupDetail): Rename inbred_set_id, inbred_set_name, inbred_set_code
fields to group_id, display_name, group_code, adding
#[mysql(rename = "...")] overrides so FromRow still matches the
InbredSetId, InbredSetName, InbredSetCode MariaDB columns; InbredSet
stays a MariaDB-only name, not a Rust identifier.
* src/lib.rs (group_by_name): Update the "group" path parameter
description to mention matching by numeric Id too.
* tests/group_by_name.rs (group_by_name_bxd_returns_group_row): Update
assertion for the display_name field rename.
(group_by_name_numeric_id_returns_same_group_row): New test.
* test/python/test_group_by_name.py: Likewise.
* README.md (GET /groups/{group}): Document matching by numeric Id and
the group_id/display_name/group_code field names.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XDDpXvZBQat9uSgDeEMJ8d
Diffstat (limited to 'test/python')
| -rw-r--r-- | test/python/test_group_by_name.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/test/python/test_group_by_name.py b/test/python/test_group_by_name.py index 440ee8b..cc8e39b 100644 --- a/test/python/test_group_by_name.py +++ b/test/python/test_group_by_name.py @@ -35,9 +35,29 @@ class GroupByNameTest(ServerTestCase): group = json.loads(body) self.assertEqual(group["name"], "BXD") - self.assertEqual(group["inbred_set_name"], "BXD") + self.assertEqual(group["display_name"], "BXD") self.assertEqual(group["genetic_type"], "riset") + def test_group_by_name_numeric_id_returns_same_group_row(self): + """BXD's InbredSet.Id is 1, same as its InbredSetId; replicates + gn-guile's gn.data.population:population-info, which looks a + group up by numeric Id rather than by name.""" + if not database_reachable(): + self.skipTest("no database on 127.0.0.1:3306") + + conn = http.client.HTTPConnection(HOST, int(PORT), timeout=10) + try: + conn.request("GET", "/groups/1") + response = conn.getresponse() + body = response.read() + finally: + conn.close() + self.assertEqual(response.status, 200) + + group = json.loads(body) + self.assertEqual(group["name"], "BXD") + self.assertEqual(group["id"], 1) + def test_group_by_name_unknown_group_returns_404(self): if not database_reachable(): self.skipTest("no database on 127.0.0.1:3306") |
