Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade for CKAN 2.9/python 3 #4

Merged
merged 17 commits into from
Jan 27, 2021
Merged

Upgrade for CKAN 2.9/python 3 #4

merged 17 commits into from
Jan 27, 2021

Conversation

chris48s
Copy link
Member

This PR has ended up quite big and sprawling, but I think I've done a pretty decent job of making each commit a sensible unit to review at least. High-level things going on in this PR:

  • Delete stuff we are not using
  • Make the plugin compatible with CKAN 2.8/py2, CKAN 2.9/py2, CKAN 2.9/py3
  • Add some top-level integration tests. There is a pretty decent chunk of this that is still not under test (esp the integration with scheming), but it is a start..
  • Run the tests in CI using GH actions

return open(os.path.join(os.path.dirname(__file__), 'test_data', filename), 'rb')


def _patch_storage_path(monkeypatch, tmpdir, ckan_config):
Copy link
Member Author

Choose a reason for hiding this comment

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

Unforuntately I wasn't able to do this in setup() because it doesn't get passed the vars monkeypatch, tmpdir and ckan_config so I am just calling _patch_storage_path(monkeypatch, tmpdir, ckan_config) at the start of every test that needs it. Can you think of any way round this that would allow us to do this in setup()?

Copy link
Member

Choose a reason for hiding this comment

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

What about creating your own patch_storage fixture that does this and applying it to the class alongside clean_db etc?

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. I think I'm going to punt this job to an issue

):
_patch_storage_path(monkeypatch, tmpdir, ckan_config)
# TODO: test importing from URLs, mock the HTTP requests with responses
"""
Copy link
Member Author

Choose a reason for hiding this comment

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

As noted in the top post, there's a bunch of stuff I haven't tested, but I didn't want this to turn into too much of a timesink. I have to stop pulling this thread somewhere. At least having got some tests written and running under CI we've got a starting point to improve from if we want to..

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good, I think what we have now is comprehensive enough.

@codecov-io
Copy link

codecov-io commented Jan 14, 2021

Codecov Report

❗ No coverage uploaded for pull request base (master@2254016). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master       #4   +/-   ##
=========================================
  Coverage          ?   82.67%           
=========================================
  Files             ?        7           
  Lines             ?      554           
  Branches          ?        0           
=========================================
  Hits              ?      458           
  Misses            ?       96           
  Partials          ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2254016...0364463. Read the comment docs.

Copy link
Member

@amercader amercader left a comment

Choose a reason for hiding this comment

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

This looks great @chris48s . Some minor comments but it is good to be merged for a new version


Make sure

* [ckanext-harvest extension](https://github.com/ckan/ckanext-harvest) and
Copy link
Member

Choose a reason for hiding this comment

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

Do we need ckanext-harvest? You've deleted the harvesters right?

Copy link
Member Author

@chris48s chris48s Jan 27, 2021

Choose a reason for hiding this comment

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

Although we have removed the harvester plugin, internally the DdiImporter module (which use to perform the import, even when initiated via the frontend) is still an implementation of HarvesterBase

from ckanext.harvest.harvesters import HarvesterBase
from ckanext.ddi.importer import metadata
from ckanext.scheming.helpers import scheming_get_dataset_schema
import ckanapi
import logging
log = logging.getLogger(__name__)
class DdiImporter(HarvesterBase):
so we do need ckanext-harvest

return open(os.path.join(os.path.dirname(__file__), 'test_data', filename), 'rb')


def _patch_storage_path(monkeypatch, tmpdir, ckan_config):
Copy link
Member

Choose a reason for hiding this comment

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

What about creating your own patch_storage fixture that does this and applying it to the class alongside clean_db etc?

):
_patch_storage_path(monkeypatch, tmpdir, ckan_config)
# TODO: test importing from URLs, mock the HTTP requests with responses
"""
Copy link
Member

Choose a reason for hiding this comment

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

Sounds good, I think what we have now is comprehensive enough.

@@ -21,7 +22,7 @@ Features:

Copy link
Member

Choose a reason for hiding this comment

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

Worth updating the features list above ^ as most of these have been removed here

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch 👍 I've pushed some more readme updates

@chris48s chris48s merged commit da110a2 into master Jan 27, 2021
@avdata99 avdata99 deleted the ckan2-9 branch February 7, 2023 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants