From fb178866f4751ed8c5818f2b7c66364d1b466b71 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Sun, 16 Oct 2016 03:55:37 -0700 Subject: [PATCH] Fixes an issue with the source tests failing. (#456) --- lemur/tests/conftest.py | 8 ++++++++ lemur/tests/plugins/source_plugin.py | 16 ++++++++++++++++ lemur/tests/test_sources.py | 6 +++--- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 lemur/tests/plugins/source_plugin.py diff --git a/lemur/tests/conftest.py b/lemur/tests/conftest.py index 98ffb438..24637277 100644 --- a/lemur/tests/conftest.py +++ b/lemur/tests/conftest.py @@ -163,6 +163,14 @@ def destination_plugin(): return TestDestinationPlugin +@pytest.fixture +def source_plugin(): + from lemur.plugins.base import register + from .plugins.source_plugin import TestSourcePlugin + register(TestSourcePlugin) + return TestSourcePlugin + + @pytest.yield_fixture(scope="function") def logged_in_user(session, app): with app.test_request_context(): diff --git a/lemur/tests/plugins/source_plugin.py b/lemur/tests/plugins/source_plugin.py new file mode 100644 index 00000000..c08e7390 --- /dev/null +++ b/lemur/tests/plugins/source_plugin.py @@ -0,0 +1,16 @@ +from lemur.plugins.bases import SourcePlugin + + +class TestSourcePlugin(SourcePlugin): + title = 'Test' + slug = 'test-source' + description = 'Enables testing' + + author = 'Kevin Glisson' + author_url = 'https://github.com/netflix/lemur.git' + + def __init__(self, *args, **kwargs): + super(TestSourcePlugin, self).__init__(*args, **kwargs) + + def get_certificates(self): + return diff --git a/lemur/tests/test_sources.py b/lemur/tests/test_sources.py index c3dd613c..7b428505 100644 --- a/lemur/tests/test_sources.py +++ b/lemur/tests/test_sources.py @@ -39,8 +39,8 @@ def test_create_certificate(source): (VALID_ADMIN_HEADER_TOKEN, 404), ('', 401) ]) -def test_source_get(client, token, status): - assert client.get(api.url_for(Sources, source_id=1), headers=token).status_code == status +def test_source_get(client, source_plugin, token, status): + assert client.get(api.url_for(Sources, source_id=43543), headers=token).status_code == status @pytest.mark.parametrize("token,status", [ @@ -84,7 +84,7 @@ def test_source_patch(client, token, status): (VALID_ADMIN_HEADER_TOKEN, 200), ('', 401) ]) -def test_sources_list_get(client, token, status): +def test_sources_list_get(client, source_plugin, token, status): assert client.get(api.url_for(SourcesList), headers=token).status_code == status