Spaces:
Running
Running
Download tests/test_knowledge_metadata.py from BravoRobots/lexia: direct link, hf CLI and curl.
- Browser
- Download file 2.37 kB
-
https://huggingface.co/spaces/BravoRobots/lexia/resolve/main/tests/test_knowledge_metadata.py
- Command line
-
hf download hf://spaces/BravoRobots/lexia/tests/test_knowledge_metadata.py
-
curl -L -o test_knowledge_metadata.py https://huggingface.co/spaces/BravoRobots/lexia/resolve/main/tests/test_knowledge_metadata.py
2.37 kB
| """Trazabilidad obligatoria de las fuentes oficiales en SQLite.""" | |
| from __future__ import annotations | |
| import json | |
| from lexia.knowledge.database import SCHEMA_VERSION, LegalKnowledgeDatabase | |
| def test_sql_conserva_metadatos_de_la_fuente_y_los_devuelve_en_la_busqueda(tmp_path): | |
| manifest = tmp_path / "sources.json" | |
| records = tmp_path / "records.jsonl" | |
| manifest.write_text( | |
| json.dumps( | |
| { | |
| "schema_version": 3, | |
| "release": "test", | |
| "checked_on": "2026-09-16", | |
| "sources": [ | |
| { | |
| "id": "edpb-opinion", | |
| "identifier": "EDPB-28-2024", | |
| "title": "Opinión EDPB sobre modelos de IA", | |
| "official_url": "https://www.edpb.europa.eu/opinion", | |
| "download_url": "https://www.edpb.europa.eu/opinion.pdf", | |
| "jurisdiction": "EU", | |
| "authority": 10, | |
| "nature": "official_guidance", | |
| "organization": "EDPB", | |
| "document_type": "opinión", | |
| "binding_character": "informative", | |
| "published_on": "2024-12-17", | |
| "updated_on": "2025-01-01", | |
| "entered_into_force_on": None, | |
| } | |
| ], | |
| }, | |
| ensure_ascii=False, | |
| ), | |
| encoding="utf-8", | |
| ) | |
| records.write_text( | |
| json.dumps( | |
| { | |
| "id": "edpb-opinion:page-1:1", | |
| "source_id": "edpb-opinion", | |
| "article": "page 1", | |
| "text": "Los modelos de inteligencia artificial pueden tratar datos personales.", | |
| }, | |
| ensure_ascii=False, | |
| ) | |
| + "\n", | |
| encoding="utf-8", | |
| ) | |
| database = LegalKnowledgeDatabase(tmp_path / "legal.sqlite3") | |
| assert database.sync(manifest, records) | |
| result = database.search("inteligencia artificial") | |
| assert len(result) == 1 | |
| assert result[0].organization == "EDPB" | |
| assert result[0].document_type == "opinión" | |
| assert result[0].binding_character == "informative" | |
| assert result[0].updated_on == "2025-01-01" | |
| assert database.status()["schema_version"] == str(SCHEMA_VERSION) | |