Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ckanext-odsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open-Data
ckanext-odsh
Commits
7de9f6dc
Commit
7de9f6dc
authored
6 years ago
by
anonymous
Browse files
Options
Downloads
Patches
Plain Diff
add validation unit tests
parent
ba85c965
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ckanext/odsh/tests/test_validation.py
+20
-4
20 additions, 4 deletions
ckanext/odsh/tests/test_validation.py
ckanext/odsh/validation.py
+1
-0
1 addition, 0 deletions
ckanext/odsh/validation.py
with
21 additions
and
4 deletions
ckanext/odsh/tests/test_validation.py
+
20
−
4
View file @
7de9f6dc
...
...
@@ -7,10 +7,13 @@ from mock import MagicMock, Mock, patch
def
mockInvalid
(
*
args
,
**
kwargs
):
return
Exception
(
*
args
,
**
kwargs
)
def
mock_
(
s
):
return
s
m
=
MagicMock
()
class
MissingMock
:
pass
m
.
Missing
=
MissingMock
sys
.
modules
[
'
ckan
'
]
=
MagicMock
()
sys
.
modules
[
'
ckan.plugins
'
]
=
MagicMock
()
...
...
@@ -18,14 +21,16 @@ sys.modules['ckan.plugins.toolkit'] = MagicMock()
sys
.
modules
[
'
ckan.model
'
]
=
MagicMock
()
sys
.
modules
[
'
ckan.lib
'
]
=
MagicMock
()
sys
.
modules
[
'
ckan.lib.navl
'
]
=
MagicMock
()
sys
.
modules
[
'
ckan.lib.navl.dictization_functions
'
]
=
MagicMock
()
sys
.
modules
[
'
ckan.lib.navl.dictization_functions
'
]
=
m
sys
.
modules
[
'
pylons
'
]
=
MagicMock
()
import
ckan.model
as
modelMock
import
pylons
import
ckan.plugins.toolkit
as
toolkit
toolkit
.
Invalid
=
mockInvalid
toolkit
.
_
=
mock_
import
pylons
from
ckanext.odsh.validation
import
*
...
...
@@ -67,3 +72,14 @@ def test_known_spatial_uri(url_mock, get_mock, csv_mock):
assert
data
[(
'
extras
'
,
1
,
'
value
'
)]
==
'
text
'
assert
data
[(
'
extras
'
,
2
,
'
key
'
)]
==
'
spatial
'
assert
data
[(
'
extras
'
,
2
,
'
value
'
)]
==
'
0
'
def
test_validate_licenseAttributionByText
():
# arrange
def
get_licenses
():
return
{}
modelMock
.
Package
.
get_license_register
=
get_licenses
data
=
{
'
license_id
'
:
'
0
'
,
(
'
extras
'
,
0
,
'
key
'
):
'
licenseAttributionByText
'
,
(
'
extras
'
,
0
,
'
value
'
):
''
}
validate_licenseAttributionByText
(
'
key
'
,
data
,
{},
None
)
This diff is collapsed.
Click to expand it.
ckanext/odsh/validation.py
+
1
−
0
View file @
7de9f6dc
...
...
@@ -104,6 +104,7 @@ def validate_licenseAttributionByText(key, data, errors,context):
isByLicense
=
True
break
hasAttribution
=
False
print
(
Missing
)
for
k
in
data
:
if
data
[
k
]
==
'
licenseAttributionByText
'
:
if
isinstance
(
data
[(
k
[
0
],
k
[
1
],
'
value
'
)],
Missing
)
or
(
k
[
0
],
k
[
1
],
'
value
'
)
not
in
data
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment