/usr/share/pyshared/ZEO/tests/zdoptions.test is in python-zodb 1:3.9.7-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | Minimal test of Server Options Handling
=======================================
This is initially motivated by a desire to remove the requirement of
specifying a storage name when there is only one storage.
Storage Names
-------------
It is an error not to specify any storages:
>>> import StringIO, sys, ZEO.runzeo
>>> stderr = sys.stderr
>>> open('config', 'w').write("""
... <zeo>
... address 8100
... </zeo>
... """)
>>> sys.stderr = StringIO.StringIO()
>>> options = ZEO.runzeo.ZEOOptions()
>>> options.realize('-C config'.split())
Traceback (most recent call last):
...
SystemExit: 2
>>> print sys.stderr.getvalue() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
Error: not enough values for section type 'zodb.storage';
0 found, 1 required
...
But we can specify a storage without a name:
>>> open('config', 'w').write("""
... <zeo>
... address 8100
... </zeo>
... <mappingstorage>
... </mappingstorage>
... """)
>>> options = ZEO.runzeo.ZEOOptions()
>>> options.realize('-C config'.split())
>>> [storage.name for storage in options.storages]
['1']
We can't have multiple unnamed storages:
>>> sys.stderr = StringIO.StringIO()
>>> open('config', 'w').write("""
... <zeo>
... address 8100
... </zeo>
... <mappingstorage>
... </mappingstorage>
... <mappingstorage>
... </mappingstorage>
... """)
>>> options = ZEO.runzeo.ZEOOptions()
>>> options.realize('-C config'.split())
Traceback (most recent call last):
...
SystemExit: 2
>>> print sys.stderr.getvalue() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
Error: No more than one storage may be unnamed.
...
Or an unnamed storage and one named '1':
>>> sys.stderr = StringIO.StringIO()
>>> open('config', 'w').write("""
... <zeo>
... address 8100
... </zeo>
... <mappingstorage>
... </mappingstorage>
... <mappingstorage 1>
... </mappingstorage>
... """)
>>> options = ZEO.runzeo.ZEOOptions()
>>> options.realize('-C config'.split())
Traceback (most recent call last):
...
SystemExit: 2
>>> print sys.stderr.getvalue() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
Error: Can't have an unnamed storage and a storage named 1.
...
But we can have multiple storages:
>>> open('config', 'w').write("""
... <zeo>
... address 8100
... </zeo>
... <mappingstorage x>
... </mappingstorage>
... <mappingstorage y>
... </mappingstorage>
... """)
>>> options = ZEO.runzeo.ZEOOptions()
>>> options.realize('-C config'.split())
>>> [storage.name for storage in options.storages]
['x', 'y']
As long as the names are unique:
>>> sys.stderr = StringIO.StringIO()
>>> open('config', 'w').write("""
... <zeo>
... address 8100
... </zeo>
... <mappingstorage 1>
... </mappingstorage>
... <mappingstorage 1>
... </mappingstorage>
... """)
>>> options = ZEO.runzeo.ZEOOptions()
>>> options.realize('-C config'.split())
Traceback (most recent call last):
...
SystemExit: 2
>>> print sys.stderr.getvalue() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
Error: section names must not be re-used within the same container:'1'
...
.. Cleanup =====================================================
>>> sys.stderr = stderr
|