Skip to content

Commit

Permalink
[#1879] Fix tests
Browse files Browse the repository at this point in the history
The travis setup explicitly removes the `ckan.datastore.read_url`
setting when running the tests, so we need to use a dummy one.

Also some refactoring
  • Loading branch information
amercader committed Aug 12, 2014
1 parent a259742 commit bce494b
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions ckanext/datastore/tests/test_unit.py
Expand Up @@ -3,6 +3,8 @@
import nose
import mock

from pylons import config

import ckan.tests as tests
import ckanext.datastore.db as db
import ckanext.datastore.plugin as plugin
Expand Down Expand Up @@ -38,13 +40,14 @@ def test_pg_version_check(self):
assert db._pg_version_is_at_least(connection, '8.0')
assert not db._pg_version_is_at_least(connection, '10.0')


class TestLegacyModeSetting():

@mock.patch('ckanext.datastore.db._pg_version_is_at_least')
def test_legacy_mode_set_if_no_read_url_and_pg_9(self, pgv):

pgv.return_value = True

from pylons import config

test_config = {
'ckan.datastore.write_url': config['ckan.datastore.write_url'],
}
Expand All @@ -56,8 +59,6 @@ def test_legacy_mode_set_if_no_read_url_and_pg_8(self, pgv):

pgv.return_value = False

from pylons import config

test_config = {
'ckan.datastore.write_url': config['ckan.datastore.write_url'],
}
Expand All @@ -69,11 +70,9 @@ def test_legacy_mode_set_if_read_url_and_pg_8(self, pgv):

pgv.return_value = False

from pylons import config

test_config = {
'ckan.datastore.write_url': config['ckan.datastore.write_url'],
'ckan.datastore.read_url': config['ckan.datastore.read_url'],
'ckan.datastore.read_url': 'some_test_read_url',
}

assert plugin._is_legacy_mode(test_config)
Expand All @@ -83,11 +82,9 @@ def test_legacy_mode_not_set_if_read_url_and_pg_9(self, pgv):

pgv.return_value = True

from pylons import config

test_config = {
'ckan.datastore.write_url': config['ckan.datastore.write_url'],
'ckan.datastore.read_url': config['ckan.datastore.read_url'],
'ckan.datastore.read_url': 'some_test_read_url',
}

assert not plugin._is_legacy_mode(test_config)

0 comments on commit bce494b

Please sign in to comment.