From: Karl O. Pinc Date: Sun, 15 Nov 2020 23:17:30 +0000 (-0600) Subject: Move code out of __init__.py X-Git-Url: https://papio.biology.duke.edu/gitweb/?a=commitdiff_plain;h=371c7fa452b55bacb15fc43f313e3beae1a30c5c;p=pgwui_logout Move code out of __init__.py --- diff --git a/src/pgwui_logout/__init__.py b/src/pgwui_logout/__init__.py index ef06bd3..f7a0909 100644 --- a/src/pgwui_logout/__init__.py +++ b/src/pgwui_logout/__init__.py @@ -19,27 +19,4 @@ # Karl O. Pinc -'''Provide a way to configure PGWUI. -''' - -PGWUI_COMPONENT = 'pgwui_logout' -DEFAULT_LOGOUT_ROUTE = '/logout' -DEFAULT_LOGOUT_MENU_LABEL = 'logout -- Logout from PGWUI programs' - - -def init_menu(config): - '''Add default menu information into settings when they are not present - ''' - settings = config.get_settings() - pgwui = settings.setdefault('pgwui', dict()) - pgwui.setdefault(PGWUI_COMPONENT, dict()) - pgwui[PGWUI_COMPONENT].setdefault( - 'menu_label', DEFAULT_LOGOUT_MENU_LABEL) - - -def includeme(config): - '''Pyramid configuration for PGWUI_Logout - ''' - init_menu(config) - config.add_route(PGWUI_COMPONENT, DEFAULT_LOGOUT_ROUTE) - config.scan() +from .pgwui_logout import includeme # noqa: F401 diff --git a/src/pgwui_logout/pgwui_logout.py b/src/pgwui_logout/pgwui_logout.py new file mode 100644 index 0000000..ef06bd3 --- /dev/null +++ b/src/pgwui_logout/pgwui_logout.py @@ -0,0 +1,45 @@ +# Copyright (C) 2018 The Meme Factory, Inc. http://www.meme.com/ + +# This file is part of PGWUI_Logout. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with this program. If not, see +# . +# + +# Karl O. Pinc + +'''Provide a way to configure PGWUI. +''' + +PGWUI_COMPONENT = 'pgwui_logout' +DEFAULT_LOGOUT_ROUTE = '/logout' +DEFAULT_LOGOUT_MENU_LABEL = 'logout -- Logout from PGWUI programs' + + +def init_menu(config): + '''Add default menu information into settings when they are not present + ''' + settings = config.get_settings() + pgwui = settings.setdefault('pgwui', dict()) + pgwui.setdefault(PGWUI_COMPONENT, dict()) + pgwui[PGWUI_COMPONENT].setdefault( + 'menu_label', DEFAULT_LOGOUT_MENU_LABEL) + + +def includeme(config): + '''Pyramid configuration for PGWUI_Logout + ''' + init_menu(config) + config.add_route(PGWUI_COMPONENT, DEFAULT_LOGOUT_ROUTE) + config.scan() diff --git a/tests/test___init__.py b/tests/test___init__.py deleted file mode 100644 index 66b9afb..0000000 --- a/tests/test___init__.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (C) 2018, 2019, 2020 The Meme Factory, Inc. -# http://www.karlpinc.com/ - -# This file is part of PGWUI_Logout. -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public -# License along with this program. If not, see -# . -# - -# Karl O. Pinc - -import pyramid.config -from pyramid.threadlocal import get_current_request -import pgwui_logout.__init__ as pgwui_logout_init - - -# Activiate our pytest plugin -pytest_plugins = ("pgwui",) - - -# Module packaging test - -def test_pgwui_upload_is_pgwui_component(pgwui_component_entry_point): - '''Ensure that pgwui_upload is a pgwui.component entry point - ''' - assert pgwui_component_entry_point('pgwui_logout') is True - - -# Functional tests - -# includeme() - -def test_includeme_functional(pyramid_request_config): - '''Sets a route for 'logout' - ''' - pgwui_logout_init.includeme(pyramid_request_config) - request = get_current_request() - - logout_path = request.route_path('pgwui_logout') - assert logout_path == pgwui_logout_init.DEFAULT_LOGOUT_ROUTE - - -# Integration tests - -def test_includeme_integration(): - '''Does not blow up - ''' - config = pyramid.config.Configurator() - pgwui_logout_init.includeme(config) diff --git a/tests/test_pgwui_logout.py b/tests/test_pgwui_logout.py new file mode 100644 index 0000000..381d378 --- /dev/null +++ b/tests/test_pgwui_logout.py @@ -0,0 +1,60 @@ +# Copyright (C) 2018, 2019, 2020 The Meme Factory, Inc. +# http://www.karlpinc.com/ + +# This file is part of PGWUI_Logout. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with this program. If not, see +# . +# + +# Karl O. Pinc + +import pyramid.config +from pyramid.threadlocal import get_current_request +import pgwui_logout.pgwui_logout as pgwui_logout + + +# Activiate our pytest plugin +pytest_plugins = ("pgwui",) + + +# Module packaging test + +def test_pgwui_upload_is_pgwui_component(pgwui_component_entry_point): + '''Ensure that pgwui_upload is a pgwui.component entry point + ''' + assert pgwui_component_entry_point('pgwui_logout') is True + + +# Functional tests + +# includeme() + +def test_includeme_functional(pyramid_request_config): + '''Sets a route for 'logout' + ''' + pgwui_logout.includeme(pyramid_request_config) + request = get_current_request() + + logout_path = request.route_path('pgwui_logout') + assert logout_path == pgwui_logout.DEFAULT_LOGOUT_ROUTE + + +# Integration tests + +def test_includeme_integration(): + '''Does not blow up + ''' + config = pyramid.config.Configurator() + pgwui_logout.includeme(config)