|
1 | 1 | from ted_sws.notice_publisher_triple_store.services.load_transformed_notice_into_triple_store import \ |
2 | | - load_notice_into_triple_store |
| 2 | + load_notice_into_triple_store, DEFAULT_NOTICE_REPOSITORY_NAME |
3 | 3 | from tests.fakes.fake_repository import FakeNoticeRepository |
4 | 4 |
|
5 | 5 |
|
| 6 | +SPARQL_QUERY_TRIPLES = "select * {?s ?p ?o}" |
| 7 | +SPARQL_QUERY_GRAPH = "SELECT ?g { GRAPH ?g { ?s ?p ?o } }" |
| 8 | +SPARQL_QUERY_FIXED_URI = "select * { <http://data.europa.eu/a4g/resource/ReviewerOrganisationIdentifier/2018-S-175-396207/de2507f9-ae25-37c8-809c-0109efe10669> ?p ?o .} " |
| 9 | + |
| 10 | + |
6 | 11 | def test_load_notice_into_triple_store(transformed_complete_notice, allegro_triple_store): |
7 | 12 | fake_notice_repo = FakeNoticeRepository() |
8 | 13 | fake_notice_repo.add(transformed_complete_notice) |
9 | | - |
10 | 14 | load_notice_into_triple_store(notice_id=transformed_complete_notice.ted_id, notice_repository=fake_notice_repo, |
11 | 15 | triple_store_repository=allegro_triple_store) |
12 | 16 |
|
13 | | - assert True |
| 17 | + sparql_endpoint = allegro_triple_store.get_sparql_triple_store_endpoint(DEFAULT_NOTICE_REPOSITORY_NAME) |
| 18 | + assert sparql_endpoint is not None |
| 19 | + |
| 20 | + df_query_result = sparql_endpoint.with_query(sparql_query=SPARQL_QUERY_TRIPLES).fetch_tabular() |
| 21 | + assert df_query_result is not None |
| 22 | + # assert that the graph in the triple store has more than 1 triple inside |
| 23 | + if len(df_query_result) > 0: |
| 24 | + assert True |
| 25 | + |
| 26 | + # assert that at least one graph exists in the triple store |
| 27 | + df_query_result = sparql_endpoint.with_query(sparql_query=SPARQL_QUERY_GRAPH).fetch_tabular() |
| 28 | + assert df_query_result is not None |
| 29 | + if len(df_query_result) > 0: |
| 30 | + assert True |
14 | 31 |
|
| 32 | + # assert that the there is an epo:SPARQL_QUERY_FIXED_URI object that has the value equal to the notice ID |
| 33 | + df_query_result = sparql_endpoint.with_query(sparql_query=SPARQL_QUERY_FIXED_URI).fetch_tabular() |
| 34 | + assert df_query_result is not None |
| 35 | + print(df_query_result) |
| 36 | + if len(df_query_result) > 0: |
| 37 | + assert True |
0 commit comments