Skip to content

Commit

Permalink
Open Data Soft Catalogue Prep
Browse files Browse the repository at this point in the history
  • Loading branch information
CHRISCARLON committed Sep 27, 2024
1 parent 1cce6cb commit 653af72
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ This will improve and speed up how people:

**Herding-CATs supports the following catalogues by default**

**CKAN**
**Default**
| Catalogue Name | Website | Catalogue API Endpoint Definition |
|----------------|---------|-------------------|
| London Datastore | https://data.london.gov.uk | CKAN |
| Subak Data Catalogue | https://data.subak.org | CKAN |
| Gov Open Data | https://www.data.gov.uk | CKAN |
| Humanitarian Data Exchange | https://data.humdata.org | CKAN |

| London Datastore | https://data.london.gov.uk | CKAN |✅
| Subak Data Catalogue | https://data.subak.org | CKAN |✅
| Gov Open Data | https://www.data.gov.uk | CKAN |✅
| Humanitarian Data Exchange | https://data.humdata.org | CKAN |✅
| UK Power Networks | https://ukpowernetworks.opendatasoft.com | Open Datasoft |🚧
| Infrabel | https://opendata.infrabel.be | Open Datasoft |🚧

**TBC**
| Catalogue Name | Website | Catalogue API Endpoint Definition |
Expand Down
4 changes: 2 additions & 2 deletions tests/test_endpoint_health.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from HerdingCats.session.cat_session import CkanCatSession
from HerdingCats.session.cat_session import CatSession
from HerdingCats.endpoints.api_endpoints import CkanApiPaths
import requests
from loguru import logger
Expand All @@ -12,7 +12,7 @@ def test_site_read(catalogue_url):
"""
Check that predefined data cataloues return True - means they can be used
"""
with CkanCatSession(catalogue_url) as cat_session:
with CatSession(catalogue_url) as cat_session:
url = cat_session.base_url + CkanApiPaths.SITE_READ
try:
response = cat_session.session.get(url)
Expand Down
16 changes: 8 additions & 8 deletions tests/test_package_list.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import pytest
from HerdingCats.session.cat_session import CkanCatSession
from HerdingCats.session.cat_session import CatSession
from HerdingCats.explorer.cat_explore import CkanCatExplorer
import requests
from loguru import logger

CATALOGUES = [
"https://data.london.gov.uk",
"https://data.humdata.org"
]
CATALOGUES = ["https://data.london.gov.uk", "https://data.humdata.org"]


@pytest.mark.parametrize("catalogue_url", CATALOGUES)
def test_package_list_dictionary(catalogue_url):
"""
Test the package list functionality for predefined data catalogues
"""
with CkanCatSession(catalogue_url) as cat_session:
with CatSession(catalogue_url) as cat_session:
explorer = CkanCatExplorer(cat_session)
try:

results = explorer.package_list_dictionary()

# Assert that we got a result
Expand All @@ -28,10 +25,13 @@ def test_package_list_dictionary(catalogue_url):

logger.info(f"Package search test passed for {catalogue_url}")
except requests.RequestException as e:
pytest.fail(f"Failed to perform package search for {catalogue_url}: {str(e)}")
pytest.fail(
f"Failed to perform package search for {catalogue_url}: {str(e)}"
)
except AssertionError as e:
pytest.fail(str(e))


# COULD ADD IN TESTS FOR DATAFRAME PACKAGE LIST BUT DON'T WANT TO CALL THE ENDPOINTS TOO MUCH
# THIS WOULD CALL THEM ALL 12 TIMES - TEST ABOVE SHOULD DO FOR NOW
# @pytest.mark.parametrize("catalogue_url", CATALOGUES)
Expand Down
17 changes: 12 additions & 5 deletions tests/test_session_creation.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import pytest
from HerdingCats.session.cat_session import CkanCatSession
from HerdingCats.session.cat_session import CatSession


@pytest.fixture
def domain():
return "data.london.gov.uk"


def test_cat_session_creation(domain):
"""
Check that a valid Ckan session can be created
"""
try:
session = CkanCatSession(domain)
assert isinstance(session, CkanCatSession), "CkanCatSession object should be created"
session = CatSession(domain)
assert isinstance(
session, CatSession
), "CkanCatSession object should be created"
assert session.domain == domain, "CkanCatSession should have the correct domain"
assert session.base_url == f"https://{domain}", "CkanCatSession should have the correct base URL"
assert (
session.base_url == f"https://{domain}"
), "CkanCatSession should have the correct base URL"
except Exception as e:
pytest.fail(f"Failed to create CkanCatSession: {str(e)}")


def test_cat_session_start(domain):
try:
with CkanCatSession(domain) as session:
with CatSession(domain) as session:
assert session.session is not None, "Session object should be created"
except Exception as e:
pytest.fail(f"Failed to start CkanCatSession: {str(e)}")

0 comments on commit 653af72

Please sign in to comment.