-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from open-data/test-plugin-subclass
Allow subclassing plugins to override methods
- Loading branch information
Showing
9 changed files
with
141 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
cd ckanext/scheming/tests | ||
nosetests --with-pylons=test.ini --nologcapture --with-coverage --cover-package=ckanext.scheming ckanext.scheming.tests | ||
|
||
nosetests --with-pylons=test_subclass.ini --nologcapture \ | ||
ckanext.scheming.tests.test_dataset_display \ | ||
ckanext.scheming.tests.test_form \ | ||
ckanext.scheming.tests.test_dataset_logic | ||
nosetests --with-pylons=test.ini --nologcapture \ | ||
--with-coverage --cover-package=ckanext.scheming \ | ||
ckanext.scheming.tests |
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,6 @@ | ||
import ckan.plugins as p | ||
|
||
from ckanext.scheming.plugins import SchemingDatasetsPlugin | ||
|
||
class SchemingTestSubclass(SchemingDatasetsPlugin): | ||
pass |
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,20 @@ | ||
from nose.tools import assert_raises | ||
from ckanapi import LocalCKAN, NotFound | ||
|
||
class TestDatasetSchemaLists(object): | ||
def test_dataset_schema_list(self): | ||
lc = LocalCKAN('visitor') | ||
dataset_schemas = lc.action.scheming_dataset_schema_list() | ||
assert 'camel-photos' in dataset_schemas | ||
|
||
def test_dataset_schema_show(self): | ||
lc = LocalCKAN('visitor') | ||
schema = lc.action.scheming_dataset_schema_show(type='camel-photos') | ||
assert schema['dataset_fields'][2]['label'] == 'Humps' | ||
|
||
def test_dataset_schema_not_found(self): | ||
lc = LocalCKAN('visitor') | ||
assert_raises(NotFound, | ||
lc.action.scheming_dataset_schema_show, | ||
type='ernie') | ||
|
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,33 @@ | ||
from nose.tools import assert_true | ||
|
||
from ckan.new_tests.factories import Sysadmin, Organization, Group | ||
from ckan.new_tests.helpers import FunctionalTestBase | ||
|
||
|
||
class TestOrganizationDisplay(FunctionalTestBase): | ||
def test_organization_displays_custom_fields(self): | ||
user = Sysadmin() | ||
Organization( | ||
user=user, | ||
name='org-one', | ||
department_id='3008', | ||
) | ||
|
||
app = self._get_test_app() | ||
response = app.get(url='/organization/about/org-one') | ||
assert_true('Department ID' in response.body) | ||
|
||
|
||
class TestGroupDisplay(FunctionalTestBase): | ||
def test_group_displays_custom_fields(self): | ||
user = Sysadmin() | ||
Group( | ||
user=user, | ||
name='group-one', | ||
bookface='theoneandonly', | ||
) | ||
|
||
app = self._get_test_app() | ||
response = app.get(url='/group/about/group-one') | ||
assert_true('Bookface' in response.body) | ||
|
18 changes: 1 addition & 17 deletions
18
ckanext/scheming/tests/test_logic.py → ckanext/scheming/tests/test_group_logic.py
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,55 @@ | ||
[DEFAULT] | ||
debug = true | ||
smtp_server = localhost | ||
error_email_from = paste@localhost | ||
|
||
[server:main] | ||
use = egg:Paste#http | ||
host = 0.0.0.0 | ||
port = 5000 | ||
|
||
[app:main] | ||
use = config:../../../links/ckan/test-core.ini | ||
|
||
ckan.plugins = scheming_test_subclass | ||
scheming.dataset_schemas = ckanext.scheming:camel_photos.json | ||
|
||
ckan.site_logo = /img/logo_64px_wide.png | ||
ckan.favicon = /images/icons/ckan.ico | ||
ckan.gravatar_default = identicon | ||
|
||
ckan.legacy_templates = no | ||
|
||
|
||
# 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.stdout,) | ||
level = NOTSET | ||
formatter = generic | ||
|
||
[formatter_generic] | ||
format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s |
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