Mercurial > piecrust2
comparison tests/basefs.py @ 674:f987b29d6fab
tests: Add ability to run tests with a theme site.
* Remove automatic creating of `config.yml`.
* Add option to specify `theme_config` in YAML tests.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 06 Mar 2016 23:48:01 -0800 |
parents | 152a15046b41 |
children | 72f17534d58e |
comparison
equal
deleted
inserted
replaced
673:d6403c21bdea | 674:f987b29d6fab |
---|---|
4 | 4 |
5 | 5 |
6 class TestFileSystemBase(object): | 6 class TestFileSystemBase(object): |
7 def __init__(self): | 7 def __init__(self): |
8 pass | 8 pass |
9 | |
10 def _initDefaultSpec(self): | |
11 self.withDir('counter') | |
12 self.withFile( | |
13 'kitchen/config.yml', | |
14 "site:\n title: Mock Website\n") | |
15 | 9 |
16 def path(self, p): | 10 def path(self, p): |
17 raise NotImplementedError() | 11 raise NotImplementedError() |
18 | 12 |
19 def getStructure(self, path=None): | 13 def getStructure(self, path=None): |
26 raise NotImplementedError() | 20 raise NotImplementedError() |
27 | 21 |
28 def _createFile(self, path, contents): | 22 def _createFile(self, path, contents): |
29 raise NotImplementedError() | 23 raise NotImplementedError() |
30 | 24 |
31 def getApp(self, cache=True): | 25 def getApp(self, *, cache=True, theme_site=False): |
32 root_dir = self.path('/kitchen') | 26 root_dir = self.path('/kitchen') |
33 return PieCrust(root_dir, cache=cache, debug=True) | 27 return PieCrust(root_dir, cache=cache, debug=True, |
28 theme_site=theme_site) | |
34 | 29 |
35 def withDir(self, path): | 30 def withDir(self, path): |
36 path = self.path(path) | 31 path = self.path(path) |
37 self._createDir(path) | 32 self._createDir(path) |
38 return self | 33 return self |
46 return self.withFile('kitchen/' + path, contents) | 41 return self.withFile('kitchen/' + path, contents) |
47 | 42 |
48 def withAssetDir(self, path): | 43 def withAssetDir(self, path): |
49 return self.withDir('kitchen/' + path) | 44 return self.withDir('kitchen/' + path) |
50 | 45 |
51 def withConfig(self, config): | 46 def withConfig(self, config=None): |
47 if config is None: | |
48 config = {} | |
52 return self.withFile( | 49 return self.withFile( |
53 'kitchen/config.yml', | 50 'kitchen/config.yml', |
54 yaml.dump(config)) | 51 yaml.dump(config)) |
55 | 52 |
56 def withThemeConfig(self, config): | 53 def withThemeConfig(self, config): |
57 return self.withFile( | 54 return self.withFile( |
58 'kitchen/theme/theme_config.yml', | 55 'kitchen/theme_config.yml', |
59 yaml.dump(config)) | 56 yaml.dump(config)) |
60 | 57 |
61 def withPage(self, url, config=None, contents=None): | 58 def withPage(self, url, config=None, contents=None): |
62 config = config or {} | 59 config = config or {} |
63 contents = contents or "A test page." | 60 contents = contents or "A test page." |