Commit b78e1e2a authored by thepaeth's avatar thepaeth
Browse files

init project

parents
[report]
omit =
*/site-packages/*
*/python?.?/*
ckan/*
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
container:
# The CKAN version tag of the Solr and Postgres containers should match
# the one of the container the tests run on.
# You can switch this base image with a custom image tailored to your project
image: openknowledge/ckan-dev:2.9
services:
solr:
image: ckan/ckan-solr-dev:2.9
postgres:
image: ckan/ckan-postgres-dev:2.9
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:3
env:
CKAN_SQLALCHEMY_URL: postgresql://ckan_default:pass@postgres/ckan_test
CKAN_DATASTORE_WRITE_URL: postgresql://datastore_write:pass@postgres/datastore_test
CKAN_DATASTORE_READ_URL: postgresql://datastore_read:pass@postgres/datastore_test
CKAN_SOLR_URL: http://solr:8983/solr/ckan
CKAN_REDIS_URL: redis://redis:6379/1
steps:
- uses: actions/checkout@v2
- name: Install requirements
# Install any extra requirements your extension has here (dev requirements, other extensions etc)
run: |
pip install -r requirements.txt
pip install -r dev-requirements.txt
pip install -e .
- name: Setup extension
# Extra initialization steps
run: |
# Replace default path to CKAN core config file with the one on the container
sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini
ckan -c test.ini db init
- name: Run tests
run: pytest --ckan-ini=test.ini --cov=ckanext.dataplatform --disable-warnings ckanext/dataplatform
.ropeproject
node_modules
bower_components
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
sdist/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Sphinx documentation
docs/_build/
This diff is collapsed.
include README.rst
include LICENSE
include requirements.txt
recursive-include ckanext/dataplatform *.html *.json *.js *.less *.css *.mo
[![Tests](https://github.com/NECTEC/ckanext-dataplatform/workflows/Tests/badge.svg?branch=main)](https://github.com/NECTEC/ckanext-dataplatform/actions)
# ckanext-dataplatform
**TODO:** Put a description of your extension here: What does it do? What features does it have? Consider including some screenshots or embedding a video!
## Requirements
**TODO:** For example, you might want to mention here which versions of CKAN this
extension works with.
If your extension works across different versions you can add the following table:
Compatibility with core CKAN versions:
| CKAN version | Compatible? |
| --------------- | ------------- |
| 2.6 and earlier | not tested |
| 2.7 | not tested |
| 2.8 | not tested |
| 2.9 | not tested |
Suggested values:
* "yes"
* "not tested" - I can't think of a reason why it wouldn't work
* "not yet" - there is an intention to get it working
* "no"
## Installation
**TODO:** Add any additional install steps to the list below.
For example installing any non-Python dependencies or adding any required
config settings.
To install ckanext-dataplatform:
1. Activate your CKAN virtual environment, for example:
. /usr/lib/ckan/default/bin/activate
2. Clone the source and install it on the virtualenv
git clone https://github.com/NECTEC/ckanext-dataplatform.git
cd ckanext-dataplatform
pip install -e .
pip install -r requirements.txt
3. Add `dataplatform` to the `ckan.plugins` setting in your CKAN
config file (by default the config file is located at
`/etc/ckan/default/ckan.ini`).
4. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:
sudo service apache2 reload
## Config settings
None at present
**TODO:** Document any optional config settings here. For example:
# The minimum number of hours to wait before re-checking a resource
# (optional, default: 24).
ckanext.dataplatform.some_setting = some_default_value
## Developer installation
To install ckanext-dataplatform for development, activate your CKAN virtualenv and
do:
git clone https://github.com/NECTEC/ckanext-dataplatform.git
cd ckanext-dataplatform
python setup.py develop
pip install -r dev-requirements.txt
## Tests
To run the tests, do:
pytest --ckan-ini=test.ini
## Releasing a new version of ckanext-dataplatform
If ckanext-dataplatform should be available on PyPI you can follow these steps to publish a new version:
1. Update the version number in the `setup.py` file. See [PEP 440](http://legacy.python.org/dev/peps/pep-0440/#public-version-identifiers) for how to choose version numbers.
2. Make sure you have the latest version of necessary packages:
pip install --upgrade setuptools wheel twine
3. Create a source and binary distributions of the new version:
python setup.py sdist bdist_wheel && twine check dist/*
Fix any errors you get.
4. Upload the source distribution to PyPI:
twine upload dist/*
5. Commit any outstanding changes:
git commit -a
git push
6. Tag the new release of the project on GitHub with the version number from
the `setup.py` file. For example if the version number in `setup.py` is
0.0.1 then do:
git tag 0.0.1
git push --tags
## License
[AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html)
# encoding: utf-8
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
class DataplatformPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IConfigurer)
# IConfigurer
def update_config(self, config_):
toolkit.add_template_directory(config_, 'templates')
toolkit.add_public_directory(config_, 'public')
toolkit.add_resource('fanstatic',
'dataplatform')
"""
Tests for plugin.py.
Tests are written using the pytest library (https://docs.pytest.org), and you
should read the testing guidelines in the CKAN docs:
https://docs.ckan.org/en/2.9/contributing/testing.html
To write tests for your extension you should install the pytest-ckan package:
pip install pytest-ckan
This will allow you to use CKAN specific fixtures on your tests.
For instance, if your test involves database access you can use `clean_db` to
reset the database:
import pytest
from ckan.tests import factories
@pytest.mark.usefixtures("clean_db")
def test_some_action():
dataset = factories.Dataset()
# ...
For functional tests that involve requests to the application, you can use the
`app` fixture:
from ckan.plugins import toolkit
def test_some_endpoint(app):
url = toolkit.url_for('myblueprint.some_endpoint')
response = app.get(url)
assert response.status_code == 200
To temporary patch the CKAN configuration for the duration of a test you can use:
import pytest
@pytest.mark.ckan_config("ckanext.myext.some_key", "some_value")
def test_some_action():
pass
"""
import ckanext.dataplatform.plugin as plugin
def test_plugin():
pass
[extract_messages]
keywords = translate isPlural
add_comments = TRANSLATORS:
output_file = ckanext/dataplatform/i18n/ckanext-dataplatform.pot
width = 80
[init_catalog]
domain = ckanext-dataplatform
input_file = ckanext/dataplatform/i18n/ckanext-dataplatform.pot
output_dir = ckanext/dataplatform/i18n
[update_catalog]
domain = ckanext-dataplatform
input_file = ckanext/dataplatform/i18n/ckanext-dataplatform.pot
output_dir = ckanext/dataplatform/i18n
previous = true
[compile_catalog]
domain = ckanext-dataplatform
directory = ckanext/dataplatform/i18n
statistics = true
# -*- coding: utf-8 -*-
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
from codecs import open # To use a consistent encoding
from os import path
here = path.abspath(path.dirname(__file__))
# Get the long description from the relevant file
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setup(
name='''ckanext-dataplatform''',
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# http://packaging.python.org/en/latest/tutorial.html#version
version='0.0.1',
description='''''',
long_description=long_description,
long_description_content_type="text/markdown",
# The project's main homepage.
url='https://github.com/NECTEC/ckanext-dataplatform',
# Author details
author='''thepaeth''',
author_email='''''',
# Choose your license
license='AGPL',
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 4 - Beta',
# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 2.7',
],
# What does your project relate to?
keywords='''CKAN''',
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
packages=find_packages(exclude=['contrib', 'docs', 'tests*']),
namespace_packages=['ckanext'],
install_requires=[
# CKAN extensions should not list dependencies here, but in a separate
# ``requirements.txt`` file.
#
# http://docs.ckan.org/en/latest/extensions/best-practices.html
# add-third-party-libraries-to-requirements-txt
],
# If there are data files included in your packages that need to be
# installed, specify them here. If using Python 2.6 or less, then these
# have to be included in MANIFEST.in as well.
include_package_data=True,
package_data={
},
# Although 'package_data' is the preferred approach, in some case you may
# need to place data files outside of your packages.
# see http://docs.python.org/3.4/distutils/setupscript.html
# installing-additional-files
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
data_files=[],
# To provide executable scripts, use entry points in preference to the
# "scripts" keyword. Entry points provide cross-platform support and allow
# pip to create the appropriate form of executable for the target platform.
entry_points='''
[ckan.plugins]
dataplatform=ckanext.dataplatform.plugin:DataplatformPlugin
[babel.extractors]
ckan = ckan.lib.extract:extract_ckan
''',
# If you are changing from the default layout of your extension, you may
# have to change the message extractors, you can read more about babel
# message extraction at
# http://babel.pocoo.org/docs/messages/#extraction-method-mapping-and-configuration
message_extractors={
'ckanext': [
('**.py', 'python', None),
('**.js', 'javascript', None),
('**/templates/**.html', 'ckan', None),
],
}
)
[DEFAULT]
debug = false
smtp_server = localhost
error_email_from = ckan@localhost
[app:main]
use = config:../ckan/test-core.ini
# Insert any custom config settings to be used when running your extension's
# tests here. These will override the one defined in CKAN core's test-core.ini
ckan.plugins = dataplatform
# Logging configuration
[loggers]
keys = root, ckan, sqlalchemy
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
[logger_ckan]
qualname = ckan
handlers =
level = INFO
[logger_sqlalchemy]
handlers =
qualname = sqlalchemy.engine
level = WARN
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment