Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ted 556 #273

Merged
merged 68 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
e330cc4
WIP
CaptainOfHacks Aug 19, 2022
0ff7902
Update notice_transformer.py
CaptainOfHacks Aug 21, 2022
8cd118d
Update conftest.py
CaptainOfHacks Aug 21, 2022
fe07d49
Update conftest.py
CaptainOfHacks Aug 21, 2022
4ae7c99
Update test_notice_fetcher.feature
CaptainOfHacks Aug 21, 2022
d386253
Update test_notice_fetcher.py
CaptainOfHacks Aug 21, 2022
fdf0cb0
Create __init__.py
CaptainOfHacks Aug 21, 2022
02ee7bb
Create conftest.py
CaptainOfHacks Aug 21, 2022
7c47625
Create test_notice_packager.feature
CaptainOfHacks Aug 21, 2022
73068b0
Create test_notice_packager.py
CaptainOfHacks Aug 21, 2022
d79c78b
Create __init__.py
CaptainOfHacks Aug 21, 2022
29f95dc
Create conftest.py
CaptainOfHacks Aug 21, 2022
b53ab7a
Create test_notice_publisher.feature
CaptainOfHacks Aug 21, 2022
0961362
Create test_notice_publisher.py
CaptainOfHacks Aug 21, 2022
1c6c24c
Create conftest.py
CaptainOfHacks Aug 21, 2022
1fc9cb5
Update test_notice_transformer.feature
CaptainOfHacks Aug 21, 2022
c693441
Update test_notice_transformer.py
CaptainOfHacks Aug 21, 2022
69871a8
Delete test_notice_transformer_tmp.py
CaptainOfHacks Aug 21, 2022
78b59b0
Update Makefile
CaptainOfHacks Aug 21, 2022
63033e8
Update conftest.py
CaptainOfHacks Aug 21, 2022
1c89a21
Create __init__.py
CaptainOfHacks Aug 21, 2022
71a5051
Create conftest.py
CaptainOfHacks Aug 21, 2022
4afb27f
Create test_creating_notice.feature
CaptainOfHacks Aug 21, 2022
be2df0f
Create test_creating_notice.py
CaptainOfHacks Aug 21, 2022
4bc7824
Create test_notice_operations.feature
CaptainOfHacks Aug 21, 2022
fb4ec38
Create test_notice_operations.py
CaptainOfHacks Aug 21, 2022
22012c5
Update conftest.py
CaptainOfHacks Aug 21, 2022
cbf5fa4
Create conftest.py
CaptainOfHacks Aug 21, 2022
adf89bb
Create metadata_normaliser.feature
CaptainOfHacks Aug 21, 2022
8386637
Create notice_extractor.feature
CaptainOfHacks Aug 21, 2022
e96e200
Create test_metadata_normaliser.py
CaptainOfHacks Aug 21, 2022
ad40b65
Create test_notice_eligibility.feature
CaptainOfHacks Aug 21, 2022
0a0670e
Create test_notice_eligibility.py
CaptainOfHacks Aug 21, 2022
be7a2d2
Delete test_notice_eligiblity.feature
CaptainOfHacks Aug 21, 2022
fd6b461
Create test_notice_extractor.py
CaptainOfHacks Aug 21, 2022
a050074
Create conftest.py
CaptainOfHacks Aug 21, 2022
3befd5c
Update test_notice_validator.feature
CaptainOfHacks Aug 21, 2022
d4cb1b8
Create test_notice_validator.py
CaptainOfHacks Aug 21, 2022
0e0f7e2
Update __init__.py
CaptainOfHacks Aug 21, 2022
32f174e
Update conftest.py
CaptainOfHacks Aug 21, 2022
ebca9de
Update test_notice_operations.py
CaptainOfHacks Aug 21, 2022
cf8db60
Update supra_notice.py
CaptainOfHacks Aug 22, 2022
b465103
Update supra_notice_repository.py
CaptainOfHacks Aug 22, 2022
69eaae8
Update test_supra_notice_repository.py
CaptainOfHacks Aug 22, 2022
da4638b
Update test_daily_supra_notice_manager.py
CaptainOfHacks Aug 22, 2022
bdd5509
Update selector_daily_fetch_orchestrator.py
CaptainOfHacks Aug 22, 2022
b0e316d
Update daily_supra_notice_manager.py
CaptainOfHacks Aug 22, 2022
141bf75
Update test_daily_supra_notice_manager.py
CaptainOfHacks Aug 22, 2022
4006f5d
Create docker-compose.yaml
CaptainOfHacks Aug 22, 2022
9f930b6
Create Dockerfile
CaptainOfHacks Aug 22, 2022
056ba12
Update Makefile
CaptainOfHacks Aug 22, 2022
8e75232
Update docker-compose.yaml
CaptainOfHacks Aug 22, 2022
296ebf7
Update conftest.py
CaptainOfHacks Aug 22, 2022
f5f7b4d
Update .gitignore
CaptainOfHacks Aug 22, 2022
4d05322
Update docker-compose.yaml
CaptainOfHacks Aug 22, 2022
accb6b3
Update Makefile
CaptainOfHacks Aug 22, 2022
f1b7f0f
Update Makefile
CaptainOfHacks Aug 22, 2022
fa4cc6a
Update Makefile
CaptainOfHacks Aug 22, 2022
b2b7d02
Update Makefile
CaptainOfHacks Aug 22, 2022
3ea3399
fix docker compose network visibility
CaptainOfHacks Aug 23, 2022
c5e2208
Merge remote-tracking branch 'origin/main'
Mihai10Mihai Sep 5, 2022
fd7fc87
made notice check-up availability in celler
Mihai10Mihai Sep 13, 2022
1b93f60
made notice check-up availability in celler
Mihai10Mihai Sep 13, 2022
4884476
Merge remote-tracking branch 'origin/main' into feature/TED-556
Mihai10Mihai Sep 13, 2022
8e02bb2
Added METS package publication validation
Sep 15, 2022
453127b
Merge remote-tracking branch 'origin/main' into feature/TED-556
Sep 15, 2022
5ff158c
Added METS package publication validation
Sep 15, 2022
3a7c96e
Added METS package publication validation
Sep 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions ted_sws/data_manager/adapters/sparql_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ class SPARQLClientPool(object):
connection_pool = {}

@staticmethod
def create_or_reuse_connection(endpoint_url: str):
def create_or_reuse_connection(endpoint_url: str, use_env_credentials: bool = True):
if endpoint_url not in SPARQLClientPool.connection_pool:
sparql_wrapper = SPARQLWrapper(endpoint_url)
sparql_wrapper.setCredentials(
user=config.AGRAPH_SUPER_USER,
passwd=config.AGRAPH_SUPER_PASSWORD
)
if use_env_credentials:
sparql_wrapper.setCredentials(
user=config.AGRAPH_SUPER_USER,
passwd=config.AGRAPH_SUPER_PASSWORD
)
SPARQLClientPool.connection_pool[endpoint_url] = sparql_wrapper
return SPARQLClientPool.connection_pool[endpoint_url]

Expand Down Expand Up @@ -117,8 +118,8 @@ def add_data_to_repository(self, file_content, repository_name, mime_type):

class SPARQLTripleStoreEndpoint(TripleStoreEndpointABC):

def __init__(self, endpoint_url: str):
self.endpoint = SPARQLClientPool.create_or_reuse_connection(endpoint_url)
def __init__(self, endpoint_url: str, use_env_credentials: bool = True):
self.endpoint = SPARQLClientPool.create_or_reuse_connection(endpoint_url, use_env_credentials)

def _set_sparql_query(self, sparql_query: str):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from ted_sws.data_manager.adapters.sparql_endpoint import SPARQLTripleStoreEndpoint

WEBAPI_SPARQL_URL = "https://publications.europa.eu/webapi/rdf/sparql"
CELLAR_NOTICE_AVAILABILITY_QUERY = "ASK {{ VALUES ?instance {{<{notice_uri}>}} ?instance ?predicate [] . }}"
WEBAPI_SPARQL_RUN_FORMAT = "application/sparql-results+json"


def check_availability_of_notice_in_cellar(notice_uri: str, endpoint_url: str = WEBAPI_SPARQL_URL) -> bool:
query = CELLAR_NOTICE_AVAILABILITY_QUERY.format(notice_uri=notice_uri)
result = SPARQLTripleStoreEndpoint(
endpoint_url=endpoint_url,
use_env_credentials=False).with_query(sparql_query=query).fetch_tree()
return result['boolean']
5 changes: 5 additions & 0 deletions tests/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ def fake_mapping_suite_id() -> str:
@pytest.fixture
def fuseki_triple_store():
return FusekiAdapter(host=config.FUSEKI_ADMIN_HOST, user=config.FUSEKI_ADMIN_USER, password=config.FUSEKI_ADMIN_PASSWORD)


@pytest.fixture
def cellar_sparql_endpoint():
return "https://publications.europa.eu/webapi/rdf/sparql"
6 changes: 1 addition & 5 deletions tests/e2e/data_manager/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
SHACLTestSuite, TransformationTestData, MappingSuite
from tests import TEST_DATA_PATH


@pytest.fixture
def query_content():
return """# title: Official name
Expand Down Expand Up @@ -213,7 +214,6 @@ def path_to_file_system_repository():

@pytest.fixture
def notice_with_distilled_status(notice_2020, rdf_file_content):

notice_2020.update_status_to(new_status=NoticeStatus.NORMALISED_METADATA)
notice_2020.update_status_to(new_status=NoticeStatus.ELIGIBLE_FOR_TRANSFORMATION)
notice_2020.update_status_to(new_status=NoticeStatus.PREPROCESSED_FOR_TRANSFORMATION)
Expand All @@ -234,7 +234,3 @@ def fake_repository_path():
def invalid_mapping_suite_id() -> str:
return "test_invalid_package"


@pytest.fixture
def cellar_sparql_endpoint():
return "https://publications.europa.eu/webapi/rdf/sparql"
5 changes: 0 additions & 5 deletions tests/e2e/notice_metadata_processor/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,3 @@ def fake_repository_path():
@pytest.fixture
def invalid_mapping_suite_id() -> str:
return "test_invalid_package"


@pytest.fixture
def cellar_sparql_endpoint():
return "https://publications.europa.eu/webapi/rdf/sparql"
10 changes: 10 additions & 0 deletions tests/e2e/notice_validator/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,13 @@ def fake_notice_F03_content(fake_repository_path, fake_mapping_suite_F03_id):
def fake_notice_F03(fake_notice_F03_content, fake_notice_id):
xml_manifestation = XMLManifestation(object_data=fake_notice_F03_content)
return Notice(ted_id=fake_notice_id, xml_manifestation=xml_manifestation)


@pytest.fixture
def valid_cellar_uri():
return 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'


@pytest.fixture
def invalid_cellar_uri():
return 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type-invalid'
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from ted_sws.notice_validator.services.check_availability_of_notice_in_cellar import \
check_availability_of_notice_in_cellar


def test_check_availability_of_notice_in_cellar(cellar_sparql_endpoint, valid_cellar_uri, invalid_cellar_uri):
assert check_availability_of_notice_in_cellar(notice_uri=valid_cellar_uri,
endpoint_url=cellar_sparql_endpoint)
assert not check_availability_of_notice_in_cellar(notice_uri=invalid_cellar_uri,
endpoint_url=cellar_sparql_endpoint)