Skip to content

Commit 3d125d7

Browse files
fix all tests
1 parent 3ff1f7e commit 3d125d7

9 files changed

Lines changed: 78 additions & 38 deletions

File tree

ted_sws/data_manager/adapters/notice_repository.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,17 @@ def write_large_field(large_field: Manifestation):
7676
write_large_field(notice.distilled_rdf_manifestation)
7777
write_large_field(notice.preprocessed_xml_manifestation)
7878
if notice.rdf_manifestation:
79-
for validation_report in notice.rdf_manifestation.validation:
79+
for validation_report in notice.rdf_manifestation.shacl_validations:
80+
write_large_field(validation_report)
81+
82+
for validation_report in notice.rdf_manifestation.sparql_validations:
8083
write_large_field(validation_report)
8184

8285
if notice.distilled_rdf_manifestation:
83-
for validation_report in notice.distilled_rdf_manifestation.validation:
86+
for validation_report in notice.distilled_rdf_manifestation.shacl_validations:
87+
write_large_field(validation_report)
88+
89+
for validation_report in notice.distilled_rdf_manifestation.sparql_validations:
8490
write_large_field(validation_report)
8591

8692
return notice
@@ -102,10 +108,16 @@ def load_large_field(large_field: Manifestation):
102108
load_large_field(large_field=notice.distilled_rdf_manifestation)
103109
load_large_field(large_field=notice.preprocessed_xml_manifestation)
104110
if notice.rdf_manifestation:
105-
for validation_report in notice.rdf_manifestation.validation:
111+
for validation_report in notice.rdf_manifestation.shacl_validations:
106112
load_large_field(validation_report)
113+
for validation_report in notice.rdf_manifestation.sparql_validations:
114+
load_large_field(validation_report)
115+
107116
if notice.distilled_rdf_manifestation:
108-
for validation_report in notice.distilled_rdf_manifestation.validation:
117+
for validation_report in notice.distilled_rdf_manifestation.shacl_validations:
118+
load_large_field(validation_report)
119+
120+
for validation_report in notice.distilled_rdf_manifestation.sparql_validations:
109121
load_large_field(validation_report)
110122

111123
return notice

ted_sws/notice_validator/entrypoints/cli/cmd_shacl_runner.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
import click
66

77
from ted_sws.core.adapters.cmd_runner import CmdRunner as BaseCmdRunner, DEFAULT_MAPPINGS_PATH, DEFAULT_OUTPUT_PATH
8-
from ted_sws.core.model.manifestation import RDFManifestation
8+
from ted_sws.core.model.manifestation import RDFManifestation, SHACLTestSuiteValidationReport
99
from ted_sws.data_manager.adapters.mapping_suite_repository import MappingSuiteRepositoryInFileSystem
1010
from ted_sws.event_manager.adapters.logger import LOG_INFO_TEXT
11-
from ted_sws.notice_validator.model.shacl_test_suite import SHACLSuiteValidationReport
12-
from ted_sws.notice_validator.services.shacl_test_suite_runner import SHACLTestSuiteRunner, SHACLReportBuilder
11+
from ted_sws.notice_validator.services.shacl_test_suite_runner import SHACLTestSuiteRunner, generate_shacl_report
1312

1413
DEFAULT_RDF_FOLDER = '{mappings_path}/{mapping_suite_id}/' + DEFAULT_OUTPUT_PATH
1514
DEFAULT_TEST_SUITE_REPORT_FOLDER = "test_suite_report"
@@ -57,8 +56,7 @@ def validate(self, rdf_file, base_report_path):
5756
shacl_test_suite=shacl_test_suite,
5857
mapping_suite=self.mapping_suite).execute_test_suite()
5958

60-
report_builder = SHACLReportBuilder(shacl_test_suite_execution=test_suite_execution)
61-
report: SHACLSuiteValidationReport = report_builder.generate_report()
59+
report: SHACLTestSuiteValidationReport = generate_shacl_report(shacl_test_suite_execution=test_suite_execution)
6260

6361
suite_id = shacl_test_suite.identifier
6462
data = report.object_data

ted_sws/notice_validator/entrypoints/cli/cmd_sparql_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import click
77

88
from ted_sws.core.adapters.cmd_runner import CmdRunner as BaseCmdRunner, DEFAULT_MAPPINGS_PATH, DEFAULT_OUTPUT_PATH
9-
from ted_sws.core.model.manifestation import RDFManifestation, RDFValidationManifestation
9+
from ted_sws.core.model.manifestation import RDFManifestation
1010
from ted_sws.data_manager.adapters.mapping_suite_repository import MappingSuiteRepositoryInFileSystem
1111
from ted_sws.event_manager.adapters.logger import LOG_INFO_TEXT
1212
from ted_sws.notice_validator.services.sparql_test_suite_runner import SPARQLTestSuiteRunner, SPARQLReportBuilder

tests/e2e/data_manager/test_notice_repository.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ def test_notice_repository_store_validation_reports_in_grid_fs(notice_with_disti
5151
validate_notice_with_shacl_suite(notice=notice, mapping_suite_package=dummy_mapping_suite)
5252
notice_repository.add(notice)
5353
result_notice = notice_repository.get(reference=notice.ted_id)
54-
for validation_report, result_validation_report in zip(notice.rdf_manifestation.validation, result_notice.rdf_manifestation.validation):
54+
for validation_report, result_validation_report in zip(notice.rdf_manifestation.shacl_validations, result_notice.rdf_manifestation.shacl_validations):
5555
assert validation_report.object_data == result_validation_report.object_data
5656

57-
for validation_report, result_validation_report in zip(notice.distilled_rdf_manifestation.validation,
58-
result_notice.distilled_rdf_manifestation.validation):
57+
for validation_report, result_validation_report in zip(notice.distilled_rdf_manifestation.shacl_validations,
58+
result_notice.distilled_rdf_manifestation.shacl_validations):
5959
assert validation_report.object_data == result_validation_report.object_data
6060

tests/features/model/conftest.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pytest
1111

1212
from ted_sws.core.model.manifestation import XMLManifestation, RDFManifestation, METSManifestation, \
13-
RDFValidationManifestation
13+
SPARQLTestSuiteValidationReport, SHACLTestSuiteValidationReport
1414
from ted_sws.core.model.metadata import TEDMetadata, NormalisedMetadata
1515
from ted_sws.core.model.notice import Notice, NoticeStatus
1616

@@ -26,13 +26,26 @@ def fetched_notice_data():
2626
@pytest.fixture(scope="function")
2727
def publicly_available_notice(fetched_notice_data, normalised_metadata_dict) -> Notice:
2828
ted_id, original_metadata, xml_manifestation = fetched_notice_data
29-
validation = RDFValidationManifestation(object_data="this is a validation report")
29+
sparql_validation = SPARQLTestSuiteValidationReport(object_data="This is validation report!",
30+
test_suite_identifier="sparql_test_id",
31+
mapping_suite_identifier="mapping_suite_id",
32+
validation_results=[])
33+
shacl_validation = SHACLTestSuiteValidationReport(object_data="This is validation report!",
34+
test_suite_identifier="shacl_test_id",
35+
mapping_suite_identifier="mapping_suite_id",
36+
validation_results=[])
3037
notice = Notice(ted_id=ted_id, original_metadata=original_metadata,
3138
xml_manifestation=xml_manifestation)
32-
notice._rdf_manifestation = RDFManifestation(object_data="RDF manifestation content", validation=[validation])
39+
notice._rdf_manifestation = RDFManifestation(object_data="RDF manifestation content",
40+
shacl_validations=[shacl_validation],
41+
sparql_validations=[sparql_validation]
42+
)
43+
notice._distilled_rdf_manifestation = RDFManifestation(object_data="RDF manifestation content",
44+
shacl_validations=[shacl_validation],
45+
sparql_validations=[sparql_validation]
46+
)
3347
notice._mets_manifestation = METSManifestation(object_data="METS manifestation content")
3448
notice._normalised_metadata = NormalisedMetadata(**normalised_metadata_dict)
35-
notice._distilled_rdf_manifestation = RDFManifestation(object_data="RDF manifestation content", validation=[validation])
3649
notice._preprocessed_xml_manifestation = xml_manifestation
3750
notice._status = NoticeStatus.PUBLICLY_AVAILABLE
3851
return notice

tests/features/model/test_notice_operations.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def step_impl(raw_notice):
117117

118118

119119
@given("the notice already contains normalised metadata")
120-
def step_impl(raw_notice,normalised_metadata_dict):
120+
def step_impl(raw_notice, normalised_metadata_dict):
121121
raw_notice.set_normalised_metadata(NormalisedMetadata(**normalised_metadata_dict))
122122
assert raw_notice.normalised_metadata is not None
123123

@@ -145,14 +145,16 @@ def step_impl(raw_notice):
145145
@then("notice contains no RDF validation")
146146
def step_impl(transformation_eligible_notice):
147147
assert transformation_eligible_notice
148-
print(f"transformation_eligible_notice.get_rdf_validation() = {transformation_eligible_notice.get_rdf_validation()}")
148+
print(
149+
f"transformation_eligible_notice.get_rdf_validation() = {transformation_eligible_notice.get_rdf_validation()}")
149150
assert transformation_eligible_notice.get_rdf_validation() == []
150151

151152

152153
@then("notice not contains RDF validation")
153154
def step_impl(transformation_eligible_notice):
154155
assert transformation_eligible_notice
155-
print(f"transformation_eligible_notice.get_rdf_validation() = {transformation_eligible_notice.get_rdf_validation()}")
156+
print(
157+
f"transformation_eligible_notice.get_rdf_validation() = {transformation_eligible_notice.get_rdf_validation()}")
156158
assert transformation_eligible_notice.get_rdf_validation() is None
157159

158160

@@ -202,7 +204,10 @@ def step_impl(transformation_eligible_notice, old_rdf_manifestation, rdf_manifes
202204

203205
@given("RDF validation report", target_fixture="rdf_validation")
204206
def step_impl():
205-
return RDFValidationManifestation(object_data="this is another validation report")
207+
return RDFValidationManifestation(object_data="this is another validation report",
208+
test_suite_identifier="test_suite_id",
209+
mapping_suite_identifier="mapping_suite_id"
210+
)
206211

207212

208213
@given("the notice contains an RDF manifestation")
@@ -224,7 +229,7 @@ def step_impl(transformation_eligible_notice):
224229

225230
@then("the notice status is VALIDATED")
226231
def step_impl(transformation_eligible_notice):
227-
#TODO: Change feature text and tests, once the SPARQL test suite was refactor
232+
# TODO: Change feature text and tests, once the SPARQL test suite was refactor
228233
# assert transformation_eligible_notice.status is NoticeStatus.VALIDATED
229234
assert transformation_eligible_notice.status is NoticeStatus.DISTILLED
230235
transformation_eligible_notice.update_status_to(new_status=NoticeStatus.VALIDATED)

tests/unit/core/model/conftest.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pytest
1111

1212
from ted_sws.core.model.manifestation import XMLManifestation, RDFManifestation, METSManifestation, \
13-
RDFValidationManifestation
13+
RDFValidationManifestation, SHACLTestSuiteValidationReport, SPARQLTestSuiteValidationReport
1414
from ted_sws.core.model.metadata import TEDMetadata, NormalisedMetadata
1515
from ted_sws.core.model.notice import Notice, NoticeStatus
1616

@@ -26,13 +26,26 @@ def fetched_notice_data():
2626
@pytest.fixture(scope="function")
2727
def publicly_available_notice(fetched_notice_data, normalised_metadata_dict) -> Notice:
2828
ted_id, original_metadata, xml_manifestation = fetched_notice_data
29-
validation = RDFValidationManifestation(object_data="this is a validation report")
29+
sparql_validation = SPARQLTestSuiteValidationReport(object_data="This is validation report!",
30+
test_suite_identifier="sparql_test_id",
31+
mapping_suite_identifier="mapping_suite_id",
32+
validation_results=[])
33+
shacl_validation = SHACLTestSuiteValidationReport(object_data="This is validation report!",
34+
test_suite_identifier="shacl_test_id",
35+
mapping_suite_identifier="mapping_suite_id",
36+
validation_results=[])
3037
notice = Notice(ted_id=ted_id, original_metadata=original_metadata,
3138
xml_manifestation=xml_manifestation)
32-
notice._rdf_manifestation = RDFManifestation(object_data="RDF manifestation content", validation=[validation])
39+
notice._rdf_manifestation = RDFManifestation(object_data="RDF manifestation content",
40+
shacl_validations=[shacl_validation],
41+
sparql_validations=[sparql_validation]
42+
)
43+
notice._distilled_rdf_manifestation = RDFManifestation(object_data="RDF manifestation content",
44+
shacl_validations=[shacl_validation],
45+
sparql_validations=[sparql_validation]
46+
)
3347
notice._mets_manifestation = METSManifestation(object_data="METS manifestation content")
3448
notice._normalised_metadata = NormalisedMetadata(**normalised_metadata_dict)
35-
notice._distilled_rdf_manifestation = RDFManifestation(object_data="RDF manifestation content", validation=[validation])
3649
notice._preprocessed_xml_manifestation = xml_manifestation
3750
notice._status = NoticeStatus.PUBLICLY_AVAILABLE
3851
return notice

tests/unit/core/model/test_notice_rdf_validation.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515

1616
def test_set_notice_rdf_validation(publicly_available_notice, raw_notice):
17-
validation = RDFValidationManifestation(object_data="this is a new validation report")
1817
shacl_validation = SHACLTestSuiteValidationReport(object_data="this is a shacl validation report",
1918
test_suite_identifier="shacl_test_suite_id",
2019
mapping_suite_identifier="mapping_suite_id",
@@ -30,11 +29,10 @@ def test_set_notice_rdf_validation(publicly_available_notice, raw_notice):
3029
assert raw_notice.get_distilled_rdf_validation() is None
3130
assert raw_notice.get_rdf_validation() is None
3231
with pytest.raises(ValueError):
33-
raw_notice.set_rdf_validation(validation)
32+
raw_notice.set_rdf_validation(shacl_validation)
3433

3534

3635
def test_set_notice_distilled_rdf_validation(publicly_available_notice, raw_notice):
37-
validation = RDFValidationManifestation(object_data="this is a new validation report")
3836
shacl_validation = SHACLTestSuiteValidationReport(object_data="this is a shacl validation report",
3937
test_suite_identifier="shacl_test_suite_id",
4038
mapping_suite_identifier="mapping_suite_id",
@@ -47,4 +45,4 @@ def test_set_notice_distilled_rdf_validation(publicly_available_notice, raw_noti
4745
assert publicly_available_notice.mets_manifestation is None
4846

4947
with pytest.raises(ValueError):
50-
raw_notice.set_distilled_rdf_validation(validation)
48+
raw_notice.set_distilled_rdf_validation(shacl_validation)
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ted_sws.notice_validator.model.sparql_test_suite import SPARQLQuery, SPARQLQueryResult, SPARQLTestSuiteExecution
1+
from ted_sws.core.model.manifestation import SPARQLQuery, SPARQLQueryResult, SPARQLTestSuiteValidationReport
22

33

44
def test_sparql_query(query_content):
@@ -9,7 +9,7 @@ def test_sparql_query(query_content):
99

1010
def test_sparql_query_result(query_content):
1111
sparql_query = SPARQLQuery(query=query_content)
12-
sparql_query_result = SPARQLQueryResult(query=sparql_query,result="pass")
12+
sparql_query_result = SPARQLQueryResult(query=sparql_query, result="pass")
1313
assert "pass" == sparql_query_result.result
1414
assert isinstance(sparql_query_result, SPARQLQueryResult)
1515
assert "ASK" in sparql_query_result.query.query
@@ -20,10 +20,11 @@ def test_sparql_test_suite_execution(query_content):
2020
sparql_query_result_one = SPARQLQueryResult(query=sparql_query, result="pass")
2121
sparql_query_result_two = SPARQLQueryResult(query=sparql_query, result="fail")
2222
execution_results = [sparql_query_result_one, sparql_query_result_two]
23-
test_suite_execution = SPARQLTestSuiteExecution(sparql_test_suite_identifier="cool",
24-
mapping_suite_identifier="awesome",
25-
object_data="RDFValidationManifestation here")
26-
test_suite_execution.execution_results = execution_results
23+
test_suite_execution = SPARQLTestSuiteValidationReport(test_suite_identifier="cool",
24+
mapping_suite_identifier="awesome",
25+
object_data="RDFValidationManifestation here",
26+
validation_results=execution_results
27+
)
2728
assert test_suite_execution.created
28-
assert isinstance(test_suite_execution, SPARQLTestSuiteExecution)
29-
assert len(test_suite_execution.execution_results) == 2
29+
assert isinstance(test_suite_execution, SPARQLTestSuiteValidationReport)
30+
assert len(test_suite_execution.validation_results) == 2

0 commit comments

Comments
 (0)