Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Commit

Permalink
Fixes tests failing with latest onegov.core release
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Krienbühl committed May 15, 2018
1 parent 1db4506 commit 34bee12
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions onegov/election_day/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from uuid import uuid4


def write_config(path, postgres_dsn, temporary_directory):
def write_config(path, postgres_dsn, temporary_directory, redis_url):
cfg = {
'applications': [
{
Expand All @@ -24,6 +24,7 @@ def write_config(path, postgres_dsn, temporary_directory):
'namespace': 'onegov_election_day',
'configuration': {
'dsn': postgres_dsn,
'redis_url': redis_url,
'depot_backend': 'depot.io.memory.MemoryFileStorage',
'filestorage': 'fs.osfs.OSFS',
'filestorage_options': {
Expand All @@ -37,7 +38,6 @@ def write_config(path, postgres_dsn, temporary_directory):
),
'lockfile_path': temporary_directory,
'd3_renderer': 'http://localhost:1337',
'disable_memcached': True
},
}
]
Expand Down Expand Up @@ -76,10 +76,10 @@ def run_command(cfg_path, principal, commands):
] + commands)


def test_add_instance(postgres_dsn, temporary_directory):
def test_add_instance(postgres_dsn, temporary_directory, redis_url):

cfg_path = os.path.join(temporary_directory, 'onegov.yml')
write_config(cfg_path, postgres_dsn, temporary_directory)
write_config(cfg_path, postgres_dsn, temporary_directory, redis_url)
write_principal(temporary_directory, 'Govikon')

result = run_command(cfg_path, 'govikon', ['add'])
Expand All @@ -91,21 +91,22 @@ def test_add_instance(postgres_dsn, temporary_directory):
assert "This selector may not reference an existing path" in result.output


def test_add_instance_missing_config(postgres_dsn, temporary_directory):
def test_add_instance_missing_config(postgres_dsn, temporary_directory,
redis_url):

cfg_path = os.path.join(temporary_directory, 'onegov.yml')
write_config(cfg_path, postgres_dsn, temporary_directory)
write_config(cfg_path, postgres_dsn, temporary_directory, redis_url)

result = run_command(cfg_path, 'govikon', ['add'])
assert result.exit_code == 0
assert "principal.yml not found" in result.output
assert "Instance was created successfully" in result.output


def test_fetch(postgres_dsn, temporary_directory, session_manager):
def test_fetch(postgres_dsn, temporary_directory, session_manager, redis_url):

cfg_path = os.path.join(temporary_directory, 'onegov.yml')
write_config(cfg_path, postgres_dsn, temporary_directory)
write_config(cfg_path, postgres_dsn, temporary_directory, redis_url)

assert 'onegov_election_day-thun' not in session_manager.list_schemas()
assert 'onegov_election_day-bern' not in session_manager.list_schemas()
Expand Down Expand Up @@ -282,10 +283,10 @@ def get_session(entity):
assert get_session('thun').query(ArchivedResult).count() == 4


def test_send_sms(postgres_dsn, temporary_directory):
def test_send_sms(postgres_dsn, temporary_directory, redis_url):

cfg_path = os.path.join(temporary_directory, 'onegov.yml')
write_config(cfg_path, postgres_dsn, temporary_directory)
write_config(cfg_path, postgres_dsn, temporary_directory, redis_url)
write_principal(temporary_directory, 'Govikon')
assert run_command(cfg_path, 'govikon', ['add']).exit_code == 0

Expand Down Expand Up @@ -318,7 +319,8 @@ def test_send_sms(postgres_dsn, temporary_directory):
}


def test_generate_media(postgres_dsn, temporary_directory, session_manager):
def test_generate_media(postgres_dsn, temporary_directory, session_manager,
redis_url):
session_manager.set_locale('de_CH', 'de_CH')

def add_vote(number):
Expand All @@ -342,7 +344,7 @@ def add_vote(number):
transaction.commit()

cfg_path = os.path.join(temporary_directory, 'onegov.yml')
write_config(cfg_path, postgres_dsn, temporary_directory)
write_config(cfg_path, postgres_dsn, temporary_directory, redis_url)
write_principal(temporary_directory, 'Govikon', entity='1200')
assert run_command(cfg_path, 'govikon', ['add']).exit_code == 0

Expand Down Expand Up @@ -370,9 +372,9 @@ def add_vote(number):
assert os.listdir(svg_path) == []


def test_manage_tokens(postgres_dsn, temporary_directory):
def test_manage_tokens(postgres_dsn, temporary_directory, redis_url):
cfg_path = os.path.join(temporary_directory, 'onegov.yml')
write_config(cfg_path, postgres_dsn, temporary_directory)
write_config(cfg_path, postgres_dsn, temporary_directory, redis_url)
write_principal(temporary_directory, 'Govikon')
assert run_command(cfg_path, 'govikon', ['add']).exit_code == 0

Expand Down

0 comments on commit 34bee12

Please sign in to comment.