Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
ckanpublish
Commits
1c5b5774bec7
Commit
1c657aaa
authored
Jan 21, 2015
by
Denis Laxalde
Browse files
[test] Extract test case fixtures into a mixin class
parent
2119de08f3e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
test/unittest_hooks.py
View file @
1c5b5774
...
...
@@ -4,28 +4,10 @@ from cubicweb import Binary
from
cubicweb.devtools.testlib
import
CubicWebTC
from
cubes.ckanpublish.utils
import
ckan_post
,
CKANPostError
from
cubes.ckanpublish.testutils
import
CKANPublishTestMixin
class
CKANPublishHooksTC
(
CubicWebTC
):
dataset_owner_org
=
None
@
classmethod
def
setUpClass
(
cls
):
try
:
from
ckanconfig
import
baseurl
,
apikey
,
organization
except
ImportError
:
cls
.
__unittest_skip__
=
True
cls
.
__unittest_skip_why__
=
'no CKAN instance configuration found'
else
:
cls
.
ckan_config
=
{
'ckan-baseurl'
:
baseurl
,
'ckan-api-key'
:
apikey
,
'ckan-organization'
:
organization
}
cls
.
dataset_owner_org
=
organization
def
setup_database
(
self
):
for
k
,
v
in
self
.
ckan_config
.
items
():
self
.
config
.
global_set_option
(
k
,
v
)
class
CKANPublishHooksTC
(
CKANPublishTestMixin
,
CubicWebTC
):
def
tearDown
(
self
):
with
self
.
admin_access
.
repo_cnx
()
as
cnx
:
...
...
testutils.py
0 → 100644
View file @
1c5b5774
# copyright 2015 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr -- mailto:contact@logilab.fr
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-ckanpublish test utilities"""
class
CKANPublishTestMixin
(
object
):
"""Test case mixin to handle CKAN instance configuration, setup and
teardown.
Relies on the presence of a `ckanconfig.py` module in test directory.
"""
dataset_owner_org
=
None
@
classmethod
def
setUpClass
(
cls
):
try
:
from
ckanconfig
import
baseurl
,
apikey
,
organization
except
ImportError
:
cls
.
__unittest_skip__
=
True
cls
.
__unittest_skip_why__
=
'no CKAN instance configuration found'
else
:
cls
.
ckan_config
=
{
'ckan-baseurl'
:
baseurl
,
'ckan-api-key'
:
apikey
,
'ckan-organization'
:
organization
}
cls
.
dataset_owner_org
=
organization
def
setup_database
(
self
):
for
k
,
v
in
self
.
ckan_config
.
items
():
self
.
config
.
global_set_option
(
k
,
v
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment