Skip to content

Commit

Permalink
update suffix for to_dict
Browse files Browse the repository at this point in the history
  • Loading branch information
MBueschelberger committed Dec 18, 2024
1 parent d166427 commit 34d4bed
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 2 deletions.
2 changes: 1 addition & 1 deletion data2rdf/parsers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def to_dict(
metadata = []
for metadatum in self.general_metadata:
prop = {
"label": str(metadatum.iri).split(self.config.separator)[-1],
"label": metadatum.suffix,
"value": metadatum.value,
}
if hasattr(metadatum, "measurement_unit"):
Expand Down
106 changes: 105 additions & 1 deletion tests/abox/xls_pipeline_test/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,94 @@
],
}

metadata_suffix = {
"sections": [
{
"entries": [
{
"label": "Time2",
"value": "2016-10-11 00:00:00",
},
{
"label": "OriginalGaugeLength",
"measurementUnit": {
"iri": "http://qudt.org/vocab/unit/MilliM",
"label": "Millimetre",
"namespace": "http://qudt.org/vocab/unit",
"symbol": "mm",
},
"value": 15,
},
{
"label": "SpecimenWidth",
"measurementUnit": {
"iri": "http://qudt.org/vocab/unit/MilliM",
"label": "Millimetre",
"namespace": "http://qudt.org/vocab/unit",
"symbol": "mm",
},
"value": 9.5,
},
{
"label": "SpecimenThickness",
"measurementUnit": {
"iri": "http://qudt.org/vocab/unit/MilliM",
"label": "Millimetre",
"namespace": "http://qudt.org/vocab/unit",
"symbol": "mm",
},
"value": 1.5,
},
{
"label": "SpecimenType",
"value": "Fz 10x20",
},
{
"label": "SampleIdentifier-2",
"value": "123456",
},
{
"label": "ProjectNumber",
"value": "Projekt_1",
},
{
"label": "Tester",
"value": "Fe",
},
{
"label": "TestingRate",
"measurementUnit": {
"iri": "http://qudt.org/vocab/unit/MilliM-PER-SEC",
"label": "Millimetre per Second",
"namespace": "http://qudt.org/vocab/unit",
"symbol": "mm/s",
},
"value": 0.02,
},
{
"label": "MachineData",
"value": "M_1",
},
{
"label": "Temperature",
"measurementUnit": {
"iri": "http://qudt.org/vocab/unit/DEG_C",
"label": "degree Celsius",
"namespace": "http://qudt.org/vocab/unit",
"symbol": "°C",
},
"value": 25,
},
{
"label": "Material",
"value": "Werkstoff_1",
},
],
"name": "General",
},
],
}

columns = [
"TestTime",
"StandardForce",
Expand All @@ -117,12 +205,22 @@
"WidthChange",
]

columns_suffix = [
"Time1",
"StandardForce",
"Extension",
"PercentageElongation",
"AbsoluteCrossheadTravel",
"WidthChange",
]


normal_config = {"graph_identifier": "https://www.example.org"}
bad_config = {"graph_identifier": "https://www.example.org", "foorbar": 123}


@pytest.mark.parametrize("config", [normal_config, bad_config])
def test_csv_pipeline_config(config) -> None:
def test_xlsx_pipeline_config(config) -> None:
from rdflib import Graph

from data2rdf.warnings import MappingMissmatchWarning
Expand Down Expand Up @@ -324,3 +422,9 @@ def test_excel_pipeline_suffix() -> None:
expected_graph.parse(expected)

assert pipeline.graph.isomorphic(expected_graph)

assert remove_ids(pipeline.to_dict(dsms_schema=True)) == sort_entries(
metadata_suffix
)

assert sorted(list(pipeline.time_series.columns)) == sorted(columns_suffix)

0 comments on commit 34d4bed

Please sign in to comment.