New includeme() configuration callable
authorKarl O. Pinc <kop@meme.com>
Wed, 24 Oct 2018 02:22:03 +0000 (21:22 -0500)
committerKarl O. Pinc <kop@meme.com>
Wed, 24 Oct 2018 02:22:03 +0000 (21:22 -0500)
setup.py
src/pgwui_common/configure.py [new file with mode: 0644]
src/pgwui_common/pgwui_common.py [deleted file]
tests/test_configure.py [new file with mode: 0644]
tests/test_pgwui_common.py [deleted file]

index 75c84d1250d2748afc261603029f5809c69a1d62..cb3feead13b1c7495e8b4b05ae799c8d643218af 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -131,7 +131,10 @@ setup(
     package_dir={'': 'src'},
 
     # Run-time dependencies.
-    install_requires=[],
+    install_requires=[
+        'pyramid_beaker',
+        'pyramid_mako',
+    ],
 
     # List additional groups of dependencies here (e.g. development
     # dependencies). You can install these using the following syntax,
diff --git a/src/pgwui_common/configure.py b/src/pgwui_common/configure.py
new file mode 100644 (file)
index 0000000..52c820f
--- /dev/null
@@ -0,0 +1,40 @@
+# Copyright (C) 2018 The Meme Factory, Inc.  http://www.meme.com/
+
+# This file is part of PGWUI_Common.
+#
+# 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
+# <http://www.gnu.org/licenses/>.
+#
+
+# Karl O. Pinc <kop@meme.com>
+
+'''Provide a way to configure PGWUI.
+
+To use pgwui_common configure your pyramid app by putting the
+following into your package's __init__.py:
+
+    from pyramid.config import Configurator
+
+    def main(global_config, **settings):
+        config = Configurator()
+        config.include('pgwui_common.configure.includeme')
+
+'''
+
+
+def includeme(config):
+    config.include('pyramid_mako')
+    config.include('pyramid_beaker')
+    config.add_static_view(
+        'static', 'pgwui_common:/static', cache_max_age=3600)
diff --git a/src/pgwui_common/pgwui_common.py b/src/pgwui_common/pgwui_common.py
deleted file mode 100644 (file)
index 205c4eb..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (C) 2018 The Meme Factory, Inc.  http://www.meme.com/
-
-# This file is part of PGWUI_Common.
-#
-# 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
-# <http://www.gnu.org/licenses/>.
-#
-
-# Karl O. Pinc <kop@meme.com>
-
-'''Empty module.
-'''
-
-
-def example_func():
-    return 1
diff --git a/tests/test_configure.py b/tests/test_configure.py
new file mode 100644 (file)
index 0000000..ca4eaa6
--- /dev/null
@@ -0,0 +1,41 @@
+# Copyright (C) 2018 The Meme Factory, Inc.  http://www.meme.com/
+
+# This file is part of PGWUI_Common.
+#
+# 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
+# <http://www.gnu.org/licenses/>.
+#
+
+# Karl O. Pinc <kop@meme.com>
+
+from pgwui_common import configure
+
+
+def test_configure_includecalled():
+
+    class MockConfig():
+        def __init__(self):
+            self.include_called = False
+            self.add_static_view_called = False
+
+        def include(self, *args):
+            self.include_called = True
+
+        def add_static_view(self, *args, **kwargs):
+            self.add_static_view_called = True
+
+    config = MockConfig()
+    configure.includeme(config)
+    assert config.include_called
+    assert config.add_static_view_called
diff --git a/tests/test_pgwui_common.py b/tests/test_pgwui_common.py
deleted file mode 100644 (file)
index c0fca96..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2018 The Meme Factory, Inc.  http://www.meme.com/
-
-# This file is part of PGWUI_Common.
-#
-# 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
-# <http://www.gnu.org/licenses/>.
-#
-
-# Karl O. Pinc <kop@meme.com>
-
-from pgwui_common import pgwui_common
-
-
-def test_example_func():
-    assert pgwui_common.example_func() == 1