From 19640851a4c26e2398781c1713b908ac711b2db5 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 3 Oct 2026 14:01:01 +0000 Subject: 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 Claude-Session: https://claude.ai/code/session_01XDDpXvZBQat9uSgDeEMJ8d --- test/python/test_group_by_name.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'test/python') 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") -- cgit 1.4.1