Mercurial > wikked
comparison tests/mock.py @ 448:c78eaebced8b
fs: Add support for builtin namespaces.
Add stub page for a `help` namespace.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 07 Jan 2018 11:05:55 -0800 |
parents | 64acfb58e023 |
children | 2027ab79f006 |
comparison
equal
deleted
inserted
replaced
447:8ca8c2713c92 | 448:c78eaebced8b |
---|---|
89 | 89 |
90 | 90 |
91 class MockFileSystem(FileSystem): | 91 class MockFileSystem(FileSystem): |
92 def __init__(self, root, config, structure=None): | 92 def __init__(self, root, config, structure=None): |
93 super(MockFileSystem, self).__init__(root, config) | 93 super(MockFileSystem, self).__init__(root, config) |
94 self.include_builtin_namespaces = False | |
94 if not structure: | 95 if not structure: |
95 self.structure = {} | 96 self.structure = {} |
96 else: | 97 else: |
97 self.structure = MockFileSystem.flat_to_nested(structure) | 98 self.structure = MockFileSystem.flat_to_nested(structure) |
98 | 99 |
99 def getPageInfos(self, subdir=None): | 100 def getPageInfos(self, subdir=None): |
100 def tmp_walk(path): | 101 def tmp_walk(path): |
101 node = self._getNode(path) | 102 node = self._getNode(path) |
103 if node is None: | |
104 raise Exception("No node at %s" % path) | |
102 return mock_os_walk(path, node) | 105 return mock_os_walk(path, node) |
103 | 106 |
104 orig_walk = os.walk | 107 orig_walk = os.walk |
105 os.walk = tmp_walk | 108 os.walk = tmp_walk |
106 try: | 109 try: |
132 return node | 135 return node |
133 | 136 |
134 def _getPhysicalPath(self, url, is_file=True, make_new=False): | 137 def _getPhysicalPath(self, url, is_file=True, make_new=False): |
135 def tmp_walk(path): | 138 def tmp_walk(path): |
136 node = self._getNode(path) | 139 node = self._getNode(path) |
140 if node is None: | |
141 raise Exception("No node at %s" % path) | |
137 return mock_os_walk(path, node) | 142 return mock_os_walk(path, node) |
138 | 143 |
139 orig_walk = os.walk | 144 orig_walk = os.walk |
140 os.walk = tmp_walk | 145 os.walk = tmp_walk |
141 try: | 146 try: |