diff --git a/src/zbmath_rest2oai/software_quickstatements.py b/src/zbmath_rest2oai/software_quickstatements.py index 758e63d..117769e 100644 --- a/src/zbmath_rest2oai/software_quickstatements.py +++ b/src/zbmath_rest2oai/software_quickstatements.py @@ -8,7 +8,7 @@ JSON schema:: - {"rows": [{"qP13": "825", "Len": "SageMath", "P29": "...", ...}, ...]} + [{"qP13": "825", "Len": "SageMath", "P29": "...", ...}, ...] Key conventions (matching MathSearch QuickStatements job): - ``qP`` – look up item whose property P equals the value. @@ -124,7 +124,7 @@ def to_reference_rows(result: dict) -> list[dict]: return rows -def build_metadata_json(results: list[dict]) -> dict: +def build_metadata_json(results: list[dict]) -> list[dict]: """Build the metadata QuickStatements JSON structure. Parameters @@ -134,13 +134,13 @@ def build_metadata_json(results: list[dict]) -> dict: Returns ------- - dict - ``{"rows": [...]}`` ready to be serialised with ``json.dumps``. + list[dict] + List of rows ready to be serialised with ``json.dumps``. """ - return {"rows": [to_metadata_row(r) for r in results]} + return [to_metadata_row(r) for r in results] -def build_references_json(results: list[dict]) -> dict: +def build_references_json(results: list[dict]) -> list[dict]: """Build the references QuickStatements JSON structure. Parameters @@ -150,10 +150,10 @@ def build_references_json(results: list[dict]) -> dict: Returns ------- - dict - ``{"rows": [...]}`` ready to be serialised with ``json.dumps``. + list[dict] + List of rows ready to be serialised with ``json.dumps``. """ rows: list[dict] = [] for r in results: rows.extend(to_reference_rows(r)) - return {"rows": rows} + return rows diff --git a/test/data/software/sagemath_825_metadata.json b/test/data/software/sagemath_825_metadata.json index 987a0f3..c8de0e7 100644 --- a/test/data/software/sagemath_825_metadata.json +++ b/test/data/software/sagemath_825_metadata.json @@ -1,99 +1,97 @@ -{ - "rows": [ - { - "qP13": "825", - "Len": "SageMath", - "P29": "https://www.sagemath.org/", - "P339": "https://github.com/sagemath/sage", - "P226_1": "05", - "P226_2": "11", - "P226_3": "14", - "P226_4": "20", - "P226_5": "68", - "P226_6": "00", - "P226_7": "01", - "P226_8": "03", - "P226_9": "06", - "P226_10": "08", - "P226_11": "12", - "P226_12": "13", - "P226_13": "15", - "P226_14": "16", - "P226_15": "17", - "P226_16": "18", - "P226_17": "19", - "P226_18": "22", - "P226_19": "26", - "P226_20": "28", - "P226_21": "30", - "P226_22": "31", - "P226_23": "32", - "P226_24": "33", - "P226_25": "34", - "P226_26": "35", - "P226_27": "37", - "P226_28": "39", - "P226_29": "40", - "P226_30": "41", - "P226_31": "42", - "P226_32": "43", - "P226_33": "44", - "P226_34": "46", - "P226_35": "47", - "P226_36": "49", - "P226_37": "51", - "P226_38": "52", - "P226_39": "53", - "P226_40": "54", - "P226_41": "55", - "P226_42": "57", - "P226_43": "58", - "P226_44": "60", - "P226_45": "62", - "P226_46": "65", - "P226_47": "70", - "P226_48": "74", - "P226_49": "76", - "P226_50": "78", - "P226_51": "80", - "P226_52": "81", - "P226_53": "82", - "P226_54": "83", - "P226_55": "85", - "P226_56": "86", - "P226_57": "90", - "P226_58": "91", - "P226_59": "92", - "P226_60": "93", - "P226_61": "94", - "P226_62": "97", - "P1458q13_1": "540", - "P1458q13_2": "23170", - "P1458q13_3": "320", - "P1458q13_4": "7248", - "P1458q13_5": "680", - "P1458q13_6": "866", - "P1458q13_7": "537", - "P1458q13_8": "554", - "P1458q13_9": "16448", - "P1458q13_10": "7249", - "P1458q13_11": "545", - "P1458q13_12": "14460", - "P1458q13_13": "27596", - "P1458q13_14": "611", - "P1458q13_15": "7823", - "P1458q13_16": "23728", - "P1458q13_17": "4968", - "P1458q13_18": "724", - "P1458q13_19": "560", - "P1458q13_20": "6874", - "P286q1459_1": "7045592", - "P286q1459_2": "6418360", - "P286q1459_3": "6532438", - "P286q1459_4": "6462232", - "P286q1459_5": "6114556", - "P286q1459_6": "5785538", - "P286q1459_7": "5380273" - } - ] -} +[ + { + "qP13": "825", + "Len": "SageMath", + "P29": "https://www.sagemath.org/", + "P339": "https://github.com/sagemath/sage", + "P226_1": "05", + "P226_2": "11", + "P226_3": "14", + "P226_4": "20", + "P226_5": "68", + "P226_6": "00", + "P226_7": "01", + "P226_8": "03", + "P226_9": "06", + "P226_10": "08", + "P226_11": "12", + "P226_12": "13", + "P226_13": "15", + "P226_14": "16", + "P226_15": "17", + "P226_16": "18", + "P226_17": "19", + "P226_18": "22", + "P226_19": "26", + "P226_20": "28", + "P226_21": "30", + "P226_22": "31", + "P226_23": "32", + "P226_24": "33", + "P226_25": "34", + "P226_26": "35", + "P226_27": "37", + "P226_28": "39", + "P226_29": "40", + "P226_30": "41", + "P226_31": "42", + "P226_32": "43", + "P226_33": "44", + "P226_34": "46", + "P226_35": "47", + "P226_36": "49", + "P226_37": "51", + "P226_38": "52", + "P226_39": "53", + "P226_40": "54", + "P226_41": "55", + "P226_42": "57", + "P226_43": "58", + "P226_44": "60", + "P226_45": "62", + "P226_46": "65", + "P226_47": "70", + "P226_48": "74", + "P226_49": "76", + "P226_50": "78", + "P226_51": "80", + "P226_52": "81", + "P226_53": "82", + "P226_54": "83", + "P226_55": "85", + "P226_56": "86", + "P226_57": "90", + "P226_58": "91", + "P226_59": "92", + "P226_60": "93", + "P226_61": "94", + "P226_62": "97", + "P1458q13_1": "540", + "P1458q13_2": "23170", + "P1458q13_3": "320", + "P1458q13_4": "7248", + "P1458q13_5": "680", + "P1458q13_6": "866", + "P1458q13_7": "537", + "P1458q13_8": "554", + "P1458q13_9": "16448", + "P1458q13_10": "7249", + "P1458q13_11": "545", + "P1458q13_12": "14460", + "P1458q13_13": "27596", + "P1458q13_14": "611", + "P1458q13_15": "7823", + "P1458q13_16": "23728", + "P1458q13_17": "4968", + "P1458q13_18": "724", + "P1458q13_19": "560", + "P1458q13_20": "6874", + "P286q1459_1": "7045592", + "P286q1459_2": "6418360", + "P286q1459_3": "6532438", + "P286q1459_4": "6462232", + "P286q1459_5": "6114556", + "P286q1459_6": "5785538", + "P286q1459_7": "5380273" + } +] diff --git a/test/data/software/sagemath_825_references.json b/test/data/software/sagemath_825_references.json index 9df59ac..92c0462 100644 --- a/test/data/software/sagemath_825_references.json +++ b/test/data/software/sagemath_825_references.json @@ -1,16 +1,14 @@ -{ - "rows": [ - { - "qP1451": "6383667", - "P1463q13": "825" - }, - { - "qP1451": "6414141", - "P1463q13": "825" - }, - { - "qP1451": "6462232", - "P1463q13": "825" - } - ] -} +[ + { + "qP1451": "6383667", + "P1463q13": "825" + }, + { + "qP1451": "6414141", + "P1463q13": "825" + }, + { + "qP1451": "6462232", + "P1463q13": "825" + } +] diff --git a/test/test_software_quickstatements.py b/test/test_software_quickstatements.py index 8f50d9c..88a87f3 100644 --- a/test/test_software_quickstatements.py +++ b/test/test_software_quickstatements.py @@ -138,10 +138,10 @@ class TestBuildMetadataJson(unittest.TestCase): def test_structure(self): results = [{"id": 1, "name": "A"}, {"id": 2, "name": "B"}] output = build_metadata_json(results) - self.assertIn("rows", output) - self.assertEqual(len(output["rows"]), 2) - self.assertEqual(output["rows"][0]["qP13"], "1") - self.assertEqual(output["rows"][1]["qP13"], "2") + self.assertIsInstance(output, list) + self.assertEqual(len(output), 2) + self.assertEqual(output[0]["qP13"], "1") + self.assertEqual(output[1]["qP13"], "2") class TestBuildReferencesJson(unittest.TestCase): @@ -153,8 +153,8 @@ def test_structure(self): {"id": 2, "references": [20]}, ] output = build_references_json(results) - self.assertIn("rows", output) - self.assertEqual(len(output["rows"]), 3) + self.assertIsInstance(output, list) + self.assertEqual(len(output), 3) class TestSageMath825Fixture(unittest.TestCase): @@ -179,19 +179,19 @@ def test_references_match_fixture(self): def test_metadata_qp13_is_825(self): result = build_metadata_json([self.raw]) - self.assertEqual(result["rows"][0]["qP13"], "825") + self.assertEqual(result[0]["qP13"], "825") def test_metadata_label_is_sagemath(self): result = build_metadata_json([self.raw]) - self.assertEqual(result["rows"][0]["Len"], "SageMath") + self.assertEqual(result[0]["Len"], "SageMath") def test_metadata_homepage_present(self): result = build_metadata_json([self.raw]) - self.assertIn("P29", result["rows"][0]) + self.assertIn("P29", result[0]) def test_metadata_source_code_present(self): result = build_metadata_json([self.raw]) - self.assertIn("P339", result["rows"][0]) + self.assertIn("P339", result[0]) if __name__ == "__main__":