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

Merge branch 'fix-tests' into dev

parents 5f340dfd c96f5d81
Branches
Tags
1 merge request!48Merge dev into master
...@@ -3,6 +3,7 @@ import ckan.plugins.toolkit as toolkit ...@@ -3,6 +3,7 @@ import ckan.plugins.toolkit as toolkit
import ckan.model as modelMock import ckan.model as modelMock
import sys import sys
import json import json
import pytest
from mock import MagicMock, Mock, patch from mock import MagicMock, Mock, patch
...@@ -52,8 +53,8 @@ def test_tag_string_convert(): ...@@ -52,8 +53,8 @@ def test_tag_string_convert():
assert data[('tags', 1, 'name')] == 'tag2' assert data[('tags', 1, 'name')] == 'tag2'
@raises(Exception)
def test_tag_name_validator_invalid(): def test_tag_name_validator_invalid():
with pytest.raises(Exception):
tag_name_validator('&', None) tag_name_validator('&', None)
...@@ -61,7 +62,7 @@ def test_tag_name_validator_valid(): ...@@ -61,7 +62,7 @@ def test_tag_name_validator_valid():
tag_name_validator('valid', None) tag_name_validator('valid', None)
@patch('urllib2.urlopen') @patch('urllib.request.urlopen')
@patch('pylons.config.get', side_effect='foo') @patch('pylons.config.get', side_effect='foo')
@patch('csv.reader', side_effect=[[['uri', 'text', json.dumps({"geometry": 0})]]]) @patch('csv.reader', side_effect=[[['uri', 'text', json.dumps({"geometry": 0})]]])
def test_known_spatial_uri(url_mock, get_mock, csv_mock): 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): ...@@ -77,25 +78,30 @@ def test_known_spatial_uri(url_mock, get_mock, csv_mock):
assert data[('extras', 2, 'value')] == '0' assert data[('extras', 2, 'value')] == '0'
@raises(Exception) @pytest.mark.parametrize('exception_type', [Exception])
@patch('urllib2.urlopen') @patch('urllib.request.urlopen')
@patch('pylons.config.get', side_effect='foo') @patch('pylons.config.get', side_effect='foo')
@patch('csv.reader', side_effect=[[['uri', 'text', json.dumps({"geometry": 0})]]]) @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 # arrange
data = {('extras', 0, 'key'): 'spatial_uri', data = {('extras', 0, 'key'): 'spatial_uri',
('extras', 0, 'value'): ''} ('extras', 0, 'value'): ''}
# act
# act and assert
with pytest.raises(exception_type):
known_spatial_uri('spatial_uri', data, {}, None) 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 # arrange
data = {('extras', 0, 'key'): 'spatial', data = {('extras', 0, 'key'): 'spatial',
('extras', 0, 'value'): 'value', ('extras', 0, 'value'): 'value',
('extras', 1, 'key'): 'spatial_uri', ('extras', 1, 'key'): 'spatial_uri',
('extras', 1, 'value'): ''} ('extras', 1, 'value'): ''}
# act
# act and assert
with pytest.raises(exception_type):
known_spatial_uri('spatial_uri', data, {}, None) 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