From 0c05330cfc634a37938ffe28e7c60da2a7935952 Mon Sep 17 00:00:00 2001 From: Shyam Sunder Date: Sat, 28 Sep 2019 16:00:41 -0400 Subject: [PATCH] server/tests: fix failing tests --- server/szurubooru/tests/api/test_password_reset.py | 7 +++++-- server/szurubooru/tests/func/test_image_hash.py | 9 +++++++++ server/szurubooru/tests/func/test_posts.py | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/server/szurubooru/tests/api/test_password_reset.py b/server/szurubooru/tests/api/test_password_reset.py index e46dbbec..29917a07 100644 --- a/server/szurubooru/tests/api/test_password_reset.py +++ b/server/szurubooru/tests/api/test_password_reset.py @@ -8,8 +8,11 @@ from szurubooru.func import auth, mailer def inject_config(config_injector): config_injector({ 'secret': 'x', - 'base_url': 'http://example.com/', + 'domain': 'http://example.com', 'name': 'Test instance', + 'smtp': { + 'from': 'noreply@example.com', + }, }) @@ -22,7 +25,7 @@ def test_reset_sending_email(context_factory, user_factory): assert api.password_reset_api.start_password_reset( context_factory(), {'user_name': initiating_user}) == {} mailer.send_mail.assert_called_once_with( - 'noreply@Test instance', + 'noreply@example.com', 'user@example.com', 'Password reset for Test instance', 'You (or someone else) requested to reset your password ' + diff --git a/server/szurubooru/tests/func/test_image_hash.py b/server/szurubooru/tests/func/test_image_hash.py index 192d175b..ce82477c 100644 --- a/server/szurubooru/tests/func/test_image_hash.py +++ b/server/szurubooru/tests/func/test_image_hash.py @@ -1,3 +1,4 @@ +import pytest from szurubooru.func import image_hash @@ -7,8 +8,16 @@ def test_hashing(read_asset, config_injector): 'host': 'localhost', 'port': 9200, 'index': 'szurubooru_test', + 'user': 'szurubooru', + 'pass': None, }, }) + + if not image_hash.get_session().ping(): + pytest.xfail( + 'Unable to connect to ElasticSearch, ' + 'perhaps it is not available for this test?') + image_hash.purge() image_hash.add_image('test', read_asset('jpeg.jpg')) diff --git a/server/szurubooru/tests/func/test_posts.py b/server/szurubooru/tests/func/test_posts.py index d0c27ba6..fc4cfc9f 100644 --- a/server/szurubooru/tests/func/test_posts.py +++ b/server/szurubooru/tests/func/test_posts.py @@ -279,7 +279,7 @@ def test_update_post_source(): def test_update_post_source_with_too_long_string(): post = model.Post() with pytest.raises(posts.InvalidPostSourceError): - posts.update_post_source(post, 'x' * 1000) + posts.update_post_source(post, 'x' * 3000) @pytest.mark.parametrize(