-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(tests): added extract resource test [2024-11-25]
- Loading branch information
1 parent
97e1d79
commit cefb472
Showing
2 changed files
with
48 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pytest | ||
from HerdingCats.session.cat_session import CatSession | ||
from HerdingCats.explorer.cat_explore import CkanCatExplorer | ||
from HerdingCats.errors.cats_errors import CatExplorerError | ||
from loguru import logger | ||
|
||
CATALOGUES = ["https://data.london.gov.uk"] | ||
TEST_PACKAGE = "violence-reduction-unit" | ||
TEST_RESOURCE = "VRU Q1 2023-24 Dataset" | ||
|
||
def test_extract_resource_url(): | ||
"""Test successful resource URL extraction""" | ||
with CatSession(CATALOGUES[0]) as cat_session: | ||
explorer = CkanCatExplorer(cat_session) | ||
try: | ||
# First get package info | ||
package_info = explorer.package_show_info_json(TEST_PACKAGE) | ||
|
||
# Extract resource URL | ||
result = explorer.extract_resource_url(package_info, TEST_RESOURCE) | ||
|
||
logger.success(result) | ||
|
||
# Assertions | ||
assert result is not None, "Should return result for known resource" | ||
assert isinstance(result, list), "Should return a list" | ||
assert len(result) == 2, "Should return format and URL" | ||
assert isinstance(result[0], str), "Format should be string" | ||
assert isinstance(result[1], str), "URL should be string" | ||
|
||
except Exception as e: | ||
pytest.fail(f"Failed to extract resource URL: {str(e)}") |