Skip to content

Commit

Permalink
move data to fixture and refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
rshewitt committed Dec 27, 2023
1 parent bc4cfb9 commit 661225b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
18 changes: 18 additions & 0 deletions tests/unit/compare/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pytest


@pytest.fixture
def data_sources():
harvest_source = {
"1": "de955c1b-fa16-4b84-ad6c-f891ba276056", # update
"2": "6d500ebc-19f8-4541-82b0-f02ad24c82e3", # do nothing
"3": "9aeef506-fbc4-42e4-ad27-c2e7e9f0d1c5", # create
}

ckan_source = {
"1": "fcd3428b-0ba7-48da-951d-fe44606be556",
"2": "6d500ebc-19f8-4541-82b0-f02ad24c82e3",
"4": "dae9b42c-cfc5-4f71-ae97-a5b75234b14f", # delete
}

return harvest_source, ckan_source
16 changes: 2 additions & 14 deletions tests/unit/compare/test_compare.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
from harvester.compare import compare


def test_compare():
def test_compare(data_sources):
"""tests compare"""

harvest_source = {
"1": "de955c1b-fa16-4b84-ad6c-f891ba276056", # update
"2": "6d500ebc-19f8-4541-82b0-f02ad24c82e3", # do nothing
"3": "9aeef506-fbc4-42e4-ad27-c2e7e9f0d1c5", # create
}

ckan_source = {
"1": "fcd3428b-0ba7-48da-951d-fe44606be556",
"2": "6d500ebc-19f8-4541-82b0-f02ad24c82e3",
"4": "dae9b42c-cfc5-4f71-ae97-a5b75234b14f", # delete
}

compare_res = compare(harvest_source, ckan_source)
compare_res = compare(*data_sources)

assert len(compare_res["create"]) == 1
assert len(compare_res["update"]) == 1
Expand Down

1 comment on commit 661225b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
harvester
   __init__.py120100% 
   compare.py120100% 
   extract.py4877 85%
   load.py8566 93%
   transform.py1377 46%
harvester/utils
   __init__.py20100% 
   json.py40100% 
harvester/validate
   __init__.py20100% 
   dcat_us.py2433 88%
TOTAL2022389% 

Tests Skipped Failures Errors Time
24 0 💤 0 ❌ 0 🔥 47.688s ⏱️

Please sign in to comment.