Mercurial > p > roundup > code
view test/test_demo.py @ 7340:7b9bddda9d2d
Add support for demo mode in docker.
roundup/demo.py
Make changes to allow exposed port in docker to be specified
separately from the port that demo mode binds to. Also permit
bind address specification as well.
roundup/scripts/roundup_demo.py:
Update required by changes in demo.py. Also move away from
positional arguments to prefer flag arguments. Required for
passing port and host specification. Flake8 fixes.
share/man/man1/roundup-demo.1
Document use of option flags rather than positional
params. Other cleanups.
doc/installation.txt:
Document new docker modes: demo, shell and admin.
Update docs:
overview section - reorg, added template info
for the impatient section - added docker demo mode reference,
more docs on top level demo.py use.
new section on docker demo mode
removed getting roundup section. folded into installing roundup.
also prior for the impatient section describes how to download.
install via pip in venv recommended supported method
document all provided templates. not just minimal and classic.
added index references.
move sections around, decreased sectin depth, reformatting
scripts/Docker/roundup_healthcheck:
When running roundup-demo, there is no tracker spec. So default to
demo if no tracker=directory args found. Prevent's docker from
reporting an unhealthy container when running demo.
scripts/Docker/roundup_start:
implement demo, shell, admin docker modes.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 14 May 2023 09:43:53 -0400 |
| parents | 77eb1a41fc06 |
| children | 4cfaddc2d53e |
line wrap: on
line source
import unittest import os, sys, shutil from roundup.demo import install_demo, run_demo import roundup.scripts.roundup_server # https://stackoverflow.com/questions/4219717/how-to-assert-output-with-nosetest-unittest-in-python # lightly modified from contextlib import contextmanager _py3 = sys.version_info[0] > 2 if _py3: from io import StringIO # py3 else: from StringIO import StringIO # py2 @contextmanager def captured_output(): new_out, new_err = StringIO(), StringIO() old_out, old_err = sys.stdout, sys.stderr try: sys.stdout, sys.stderr = new_out, new_err yield sys.stdout, sys.stderr finally: sys.stdout, sys.stderr = old_out, old_err class TestDemo(unittest.TestCase): def setUp(self): self.home = os.path.abspath('_test_demo') def tearDown(self): try: shutil.rmtree(self.home) except FileNotFoundError: pass def run_install_demo(self, template, db="anydbm"): with captured_output() as (out, err): install_demo(self.home, db, template) output = out.getvalue().strip() print(output) # verify that db was set properly by reading config with open(self.home + "/config.ini", "r") as f: config_lines = f.readlines() self.assertIn("backend = %s\n"%db, config_lines) # dummy up the return of get_server so the serve_forever method # raises keyboard interrupt exiting the server so the test exits. gs = roundup.scripts.roundup_server.ServerConfig.get_server def raise_KeyboardInterrupt(): raise KeyboardInterrupt def test_get_server(self): httpd = gs(self) httpd.serve_forever = raise_KeyboardInterrupt return httpd roundup.scripts.roundup_server.ServerConfig.get_server = test_get_server # Run under context manager to capture output of startup text. with captured_output() as (out, err): run_demo(self.home) output = out.getvalue().strip() print(output) # if the server installed and started this will be the # last line in the output. self.assertIn("Keyboard Interrupt: exiting", output.split('\n')) def testDemoClassic(self): self.run_install_demo("classic") def testDemoMinimal(self): self.run_install_demo('../templates/minimal', db="sqlite") def testDemoJinja(self): self.run_install_demo('jinja2', db="anydbm") # verify that template was set to jinja2 by reading config with open(self.home + "/config.ini", "r") as f: config_lines = f.readlines() self.assertIn("template_engine = jinja2\n", config_lines)
