Skip to content

Commit

Permalink
add CUD tests and fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
rshewitt committed Sep 18, 2023
1 parent ed16f68 commit afb1d38
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/load/ckan/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import pytest
from harvester.load.ckan import create_ckan_entrypoint
import credentials


@pytest.fixture
def ckan_entrypoint():
return create_ckan_entrypoint(
"http://localhost:5000", credentials.ckan_catalog_dev_api_key
)


@pytest.fixture
def test_ckan_package_id():
return "e875348b-a7c3-47eb-b0c3-168d978b0c0f"


@pytest.fixture
def test_ckan_package(test_ckan_package_id):
return {
"name": "package_test",
"title": "title_test",
"owner_org": "test_org",
"tag_string": "test",
"id": test_ckan_package_id,
}


@pytest.fixture
def test_ckan_update_package(test_ckan_package_id):
return {"author": "test author", "id": test_ckan_package_id}


@pytest.fixture
def test_ckan_patch_package(test_ckan_package_id):
return {"author_email": "test@gmail.com", "id": test_ckan_package_id}
39 changes: 39 additions & 0 deletions tests/load/ckan/test_ckan_cud.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import pytest

Check failure on line 1 in tests/load/ckan/test_ckan_cud.py

View workflow job for this annotation

GitHub Actions / Python Lint

Ruff (F401)

tests/load/ckan/test_ckan_cud.py:1:8: F401 `pytest` imported but unused
from harvester.load.ckan import (
create_ckan_package,
delete_ckan_package,
patch_ckan_package,
update_ckan_package,
)


def test_create_package(ckan_entrypoint, test_ckan_package):
try:
create_ckan_package(ckan_entrypoint, test_ckan_package)
assert True
except:

Check failure on line 14 in tests/load/ckan/test_ckan_cud.py

View workflow job for this annotation

GitHub Actions / Python Lint

Ruff (E722)

tests/load/ckan/test_ckan_cud.py:14:5: E722 Do not use bare `except`
assert False


def test_update_package(ckan_entrypoint, test_ckan_update_package):
try:
update_ckan_package(ckan_entrypoint, test_ckan_update_package)
assert True
except:

Check failure on line 22 in tests/load/ckan/test_ckan_cud.py

View workflow job for this annotation

GitHub Actions / Python Lint

Ruff (E722)

tests/load/ckan/test_ckan_cud.py:22:5: E722 Do not use bare `except`
assert False


def test_patch_package(ckan_entrypoint, test_ckan_patch_package):
try:
patch_ckan_package(ckan_entrypoint, test_ckan_patch_package)
assert True
except:

Check failure on line 30 in tests/load/ckan/test_ckan_cud.py

View workflow job for this annotation

GitHub Actions / Python Lint

Ruff (E722)

tests/load/ckan/test_ckan_cud.py:30:5: E722 Do not use bare `except`
assert False


def test_delete_package(ckan_entrypoint, test_ckan_package_id):
try:
delete_ckan_package(ckan_entrypoint, {"id": test_ckan_package_id})
assert True
except:

Check failure on line 38 in tests/load/ckan/test_ckan_cud.py

View workflow job for this annotation

GitHub Actions / Python Lint

Ruff (E722)

tests/load/ckan/test_ckan_cud.py:38:5: E722 Do not use bare `except`
assert False

0 comments on commit afb1d38

Please sign in to comment.