Skip to content
Snippets Groups Projects
Commit c96f5d81 authored by Thorge Petersen's avatar Thorge Petersen
Browse files

Started fixing validation tests

parent a6d8be34
No related branches found
No related tags found
1 merge request!48Merge dev into master
......@@ -3,6 +3,7 @@ import ckan.plugins.toolkit as toolkit
import ckan.model as modelMock
import sys
import json
import pytest
from mock import MagicMock, Mock, patch
......@@ -52,8 +53,8 @@ def test_tag_string_convert():
assert data[('tags', 1, 'name')] == 'tag2'
@raises(Exception)
def test_tag_name_validator_invalid():
with pytest.raises(Exception):
tag_name_validator('&', None)
......@@ -61,7 +62,7 @@ def test_tag_name_validator_valid():
tag_name_validator('valid', None)
@patch('urllib2.urlopen')
@patch('urllib.request.urlopen')
@patch('pylons.config.get', side_effect='foo')
@patch('csv.reader', side_effect=[[['uri', 'text', json.dumps({"geometry": 0})]]])
def test_known_spatial_uri(url_mock, get_mock, csv_mock):
......@@ -77,25 +78,30 @@ def test_known_spatial_uri(url_mock, get_mock, csv_mock):
assert data[('extras', 2, 'value')] == '0'
@raises(Exception)
@patch('urllib2.urlopen')
@pytest.mark.parametrize('exception_type', [Exception])
@patch('urllib.request.urlopen')
@patch('pylons.config.get', side_effect='foo')
@patch('csv.reader', side_effect=[[['uri', 'text', json.dumps({"geometry": 0})]]])
def test_known_spatial_uri_without_uri(url_mock, get_mock, csv_mock):
def test_known_spatial_uri_without_uri(url_mock, get_mock, csv_mock, exception_type):
# arrange
data = {('extras', 0, 'key'): 'spatial_uri',
('extras', 0, 'value'): ''}
# act
# act and assert
with pytest.raises(exception_type):
known_spatial_uri('spatial_uri', data, {}, None)
def test_known_spatial_uri_without_uri_with_spatial():
@pytest.mark.parametrize('exception_type', [Exception])
def test_known_spatial_uri_without_uri_with_spatial(exception_type):
# arrange
data = {('extras', 0, 'key'): 'spatial',
('extras', 0, 'value'): 'value',
('extras', 1, 'key'): 'spatial_uri',
('extras', 1, 'value'): ''}
# act
# act and assert
with pytest.raises(exception_type):
known_spatial_uri('spatial_uri', data, {}, None)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment