Mercurial > p > roundup > code
annotate test/test_demo.py @ 7923:29a666d8a70d
issue2551285 - Remove StructuredText support
Asked on the users mailing list if anybody was using it. Got no responses.
I have never seen CI installing structuredtext packages so it's
untested as well.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 30 Apr 2024 22:27:57 -0400 |
| parents | 5b47966bf6f0 |
| children | 618dccf7199d |
| rev | line source |
|---|---|
|
7583
4cfaddc2d53e
test: do not run jinja2 demo test if jinja2 missing.
John Rouillard <rouilj@ieee.org>
parents:
6719
diff
changeset
|
1 import pytest |
|
6324
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2 import unittest |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
3 import os, sys, shutil |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
4 |
|
7912
5b47966bf6f0
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7704
diff
changeset
|
5 from os.path import normpath |
|
5b47966bf6f0
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7704
diff
changeset
|
6 |
|
6324
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
7 from roundup.demo import install_demo, run_demo |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
8 |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
9 import roundup.scripts.roundup_server |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
10 |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
11 # https://stackoverflow.com/questions/4219717/how-to-assert-output-with-nosetest-unittest-in-python |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
12 # lightly modified |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
13 from contextlib import contextmanager |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
14 _py3 = sys.version_info[0] > 2 |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
15 if _py3: |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
16 from io import StringIO # py3 |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
17 else: |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
18 from StringIO import StringIO # py2 |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
19 @contextmanager |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
20 def captured_output(): |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
21 new_out, new_err = StringIO(), StringIO() |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
22 old_out, old_err = sys.stdout, sys.stderr |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
23 try: |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
24 sys.stdout, sys.stderr = new_out, new_err |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
25 yield sys.stdout, sys.stderr |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
26 finally: |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
27 sys.stdout, sys.stderr = old_out, old_err |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
28 |
|
7583
4cfaddc2d53e
test: do not run jinja2 demo test if jinja2 missing.
John Rouillard <rouilj@ieee.org>
parents:
6719
diff
changeset
|
29 try: |
|
4cfaddc2d53e
test: do not run jinja2 demo test if jinja2 missing.
John Rouillard <rouilj@ieee.org>
parents:
6719
diff
changeset
|
30 import jinja2 |
|
4cfaddc2d53e
test: do not run jinja2 demo test if jinja2 missing.
John Rouillard <rouilj@ieee.org>
parents:
6719
diff
changeset
|
31 skip_jinja2 = lambda func, *args, **kwargs: func |
|
4cfaddc2d53e
test: do not run jinja2 demo test if jinja2 missing.
John Rouillard <rouilj@ieee.org>
parents:
6719
diff
changeset
|
32 except ImportError: |
|
4cfaddc2d53e
test: do not run jinja2 demo test if jinja2 missing.
John Rouillard <rouilj@ieee.org>
parents:
6719
diff
changeset
|
33 from .pytest_patcher import mark_class |
|
4cfaddc2d53e
test: do not run jinja2 demo test if jinja2 missing.
John Rouillard <rouilj@ieee.org>
parents:
6719
diff
changeset
|
34 skip_jinja2 = mark_class(pytest.mark.skip( |
|
4cfaddc2d53e
test: do not run jinja2 demo test if jinja2 missing.
John Rouillard <rouilj@ieee.org>
parents:
6719
diff
changeset
|
35 reason='Skipping Jinja2 tests: jinja2 library not available')) |
|
4cfaddc2d53e
test: do not run jinja2 demo test if jinja2 missing.
John Rouillard <rouilj@ieee.org>
parents:
6719
diff
changeset
|
36 |
|
6324
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
37 class TestDemo(unittest.TestCase): |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
38 def setUp(self): |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
39 self.home = os.path.abspath('_test_demo') |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
40 |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
41 def tearDown(self): |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
42 try: |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
43 shutil.rmtree(self.home) |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
44 except FileNotFoundError: |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
45 pass |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
46 |
|
6719
77eb1a41fc06
test cleanup. Make test method and convert tests to use.
John Rouillard <rouilj@ieee.org>
parents:
6545
diff
changeset
|
47 def run_install_demo(self, template, db="anydbm"): |
|
6324
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
48 with captured_output() as (out, err): |
|
6719
77eb1a41fc06
test cleanup. Make test method and convert tests to use.
John Rouillard <rouilj@ieee.org>
parents:
6545
diff
changeset
|
49 install_demo(self.home, db, template) |
|
6324
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
50 output = out.getvalue().strip() |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
51 print(output) |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
52 |
|
6719
77eb1a41fc06
test cleanup. Make test method and convert tests to use.
John Rouillard <rouilj@ieee.org>
parents:
6545
diff
changeset
|
53 # verify that db was set properly by reading config |
|
77eb1a41fc06
test cleanup. Make test method and convert tests to use.
John Rouillard <rouilj@ieee.org>
parents:
6545
diff
changeset
|
54 with open(self.home + "/config.ini", "r") as f: |
|
7585
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7583
diff
changeset
|
55 config_lines = f.read().replace("\r\n", "\n") |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7583
diff
changeset
|
56 |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7583
diff
changeset
|
57 try: |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7583
diff
changeset
|
58 # handle text files with \r\n line endings |
|
7586
859c57bc8d91
test: limit search for \r to first 100 bytes.
John Rouillard <rouilj@ieee.org>
parents:
7585
diff
changeset
|
59 config_lines.index("\r", 0, 100) |
|
7585
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7583
diff
changeset
|
60 config_lines = config_lines.replace("\r\n", "\n") |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7583
diff
changeset
|
61 except ValueError: |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7583
diff
changeset
|
62 pass |
|
6719
77eb1a41fc06
test cleanup. Make test method and convert tests to use.
John Rouillard <rouilj@ieee.org>
parents:
6545
diff
changeset
|
63 |
|
77eb1a41fc06
test cleanup. Make test method and convert tests to use.
John Rouillard <rouilj@ieee.org>
parents:
6545
diff
changeset
|
64 self.assertIn("backend = %s\n"%db, config_lines) |
|
77eb1a41fc06
test cleanup. Make test method and convert tests to use.
John Rouillard <rouilj@ieee.org>
parents:
6545
diff
changeset
|
65 |
|
6324
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
66 # dummy up the return of get_server so the serve_forever method |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
67 # raises keyboard interrupt exiting the server so the test exits. |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
68 gs = roundup.scripts.roundup_server.ServerConfig.get_server |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
69 def raise_KeyboardInterrupt(): |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
70 raise KeyboardInterrupt |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
71 |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
72 def test_get_server(self): |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
73 httpd = gs(self) |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
74 httpd.serve_forever = raise_KeyboardInterrupt |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
75 return httpd |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
76 |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
77 roundup.scripts.roundup_server.ServerConfig.get_server = test_get_server |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
78 |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
79 # Run under context manager to capture output of startup text. |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
80 with captured_output() as (out, err): |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
81 run_demo(self.home) |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
82 output = out.getvalue().strip() |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
83 print(output) |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
84 # if the server installed and started this will be the |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
85 # last line in the output. |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
86 self.assertIn("Keyboard Interrupt: exiting", output.split('\n')) |
|
3e33b22a3158
BAsic test of demo and server intialization.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
87 |
|
6719
77eb1a41fc06
test cleanup. Make test method and convert tests to use.
John Rouillard <rouilj@ieee.org>
parents:
6545
diff
changeset
|
88 def testDemoClassic(self): |
|
7704
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
89 with captured_output() as (out, err): |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
90 self.run_install_demo("classic") |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
91 self.assertIn("http://localhost:8917/demo/", out.getvalue()) |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
92 |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
93 # verify the default anydbm db is created |
|
7912
5b47966bf6f0
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7704
diff
changeset
|
94 db_file = self.home + normpath("/db/nodes.user") |
|
5b47966bf6f0
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7704
diff
changeset
|
95 db_file_dumbdbm = self.home + normpath("/db/nodes.user.dir") |
|
5b47966bf6f0
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7704
diff
changeset
|
96 self.assertTrue(os.path.isfile(db_file) or |
|
5b47966bf6f0
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7704
diff
changeset
|
97 os.path.isfile(db_file_dumbdbm), |
|
5b47966bf6f0
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7704
diff
changeset
|
98 "expected db file %s or %s does not exist" % ( |
|
5b47966bf6f0
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7704
diff
changeset
|
99 db_file, db_file_dumbdbm |
|
5b47966bf6f0
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7704
diff
changeset
|
100 )) |
|
7704
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
101 |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
102 # verify requested template was used |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
103 with open(self.home + "/TEMPLATE-INFO.txt", "r") as f: |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
104 info_lines = f.read() |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
105 |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
106 try: |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
107 # handle text files with \r\n line endings |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
108 info_lines.index("\r", 0, 100) |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
109 info_lines = info_lines.replace("\r\n", "\n") |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
110 except ValueError: |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
111 pass |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
112 |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
113 self.assertIn("Name: classic-_test_demo\n", info_lines) |
|
6545
5a3a386aa8e7
issue2551179 Load config_ini.ini ... recognize minimal template demo.py
John Rouillard <rouilj@ieee.org>
parents:
6324
diff
changeset
|
114 |
|
6719
77eb1a41fc06
test cleanup. Make test method and convert tests to use.
John Rouillard <rouilj@ieee.org>
parents:
6545
diff
changeset
|
115 def testDemoMinimal(self): |
|
7704
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
116 # test explicit path to template as others test template |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
117 # search path. |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
118 with captured_output() as (out, err): |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
119 self.run_install_demo('../templates/minimal', db="sqlite") |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
120 self.assertIn("http://localhost:8917/demo/", out.getvalue()) |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
121 |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
122 # verify the requested sqlite db file is created |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
123 db_file = self.home + "/db/db" |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
124 self.assertTrue(os.path.isfile(db_file), |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
125 "expected db file %s does not exist" % db_file) |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
126 |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
127 # verify requested template was used |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
128 with open(self.home + "/TEMPLATE-INFO.txt", "r") as f: |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
129 info_lines = f.read() |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
130 |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
131 try: |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
132 # handle text files with \r\n line endings |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
133 info_lines.index("\r", 0, 100) |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
134 info_lines = info_lines.replace("\r\n", "\n") |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
135 except ValueError: |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
136 pass |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
137 |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
138 self.assertIn("Name: minimal-_test_demo\n", info_lines) |
|
6545
5a3a386aa8e7
issue2551179 Load config_ini.ini ... recognize minimal template demo.py
John Rouillard <rouilj@ieee.org>
parents:
6324
diff
changeset
|
139 |
|
7583
4cfaddc2d53e
test: do not run jinja2 demo test if jinja2 missing.
John Rouillard <rouilj@ieee.org>
parents:
6719
diff
changeset
|
140 @skip_jinja2 |
|
6545
5a3a386aa8e7
issue2551179 Load config_ini.ini ... recognize minimal template demo.py
John Rouillard <rouilj@ieee.org>
parents:
6324
diff
changeset
|
141 def testDemoJinja(self): |
|
7704
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
142 with captured_output() as (out, err): |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
143 self.run_install_demo('jinja2', db="anydbm") |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
144 self.assertIn("http://localhost:8917/demo/", out.getvalue()) |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
145 |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
146 # verify the requested anydbm db file is created |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
147 db_file = self.home + "/db/nodes.user" |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
148 self.assertTrue(os.path.isfile(db_file), |
|
5b1163dca9e1
test: actually test output from running demo server code
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
149 "expected db file %s does not exist" % db_file) |
|
6545
5a3a386aa8e7
issue2551179 Load config_ini.ini ... recognize minimal template demo.py
John Rouillard <rouilj@ieee.org>
parents:
6324
diff
changeset
|
150 |
|
5a3a386aa8e7
issue2551179 Load config_ini.ini ... recognize minimal template demo.py
John Rouillard <rouilj@ieee.org>
parents:
6324
diff
changeset
|
151 # verify that template was set to jinja2 by reading config |
|
5a3a386aa8e7
issue2551179 Load config_ini.ini ... recognize minimal template demo.py
John Rouillard <rouilj@ieee.org>
parents:
6324
diff
changeset
|
152 with open(self.home + "/config.ini", "r") as f: |
|
7585
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7583
diff
changeset
|
153 config_lines = f.read() |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7583
diff
changeset
|
154 |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7583
diff
changeset
|
155 try: |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7583
diff
changeset
|
156 # handle text files with \r\n line endings |
|
7586
859c57bc8d91
test: limit search for \r to first 100 bytes.
John Rouillard <rouilj@ieee.org>
parents:
7585
diff
changeset
|
157 config_lines.index("\r", 0, 100) |
|
7585
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7583
diff
changeset
|
158 config_lines = config_lines.replace("\r\n", "\n") |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7583
diff
changeset
|
159 except ValueError: |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7583
diff
changeset
|
160 pass |
|
6545
5a3a386aa8e7
issue2551179 Load config_ini.ini ... recognize minimal template demo.py
John Rouillard <rouilj@ieee.org>
parents:
6324
diff
changeset
|
161 |
|
5a3a386aa8e7
issue2551179 Load config_ini.ini ... recognize minimal template demo.py
John Rouillard <rouilj@ieee.org>
parents:
6324
diff
changeset
|
162 self.assertIn("template_engine = jinja2\n", config_lines) |
|
5a3a386aa8e7
issue2551179 Load config_ini.ini ... recognize minimal template demo.py
John Rouillard <rouilj@ieee.org>
parents:
6324
diff
changeset
|
163 |
