def test_extract_podspec(self): # Verify global extract. pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'meta': { 'title@': 'Test Title', 'description@': 'Test Description', } }) pod.catalogs.extract() self.assertIn('Test Title', pod.catalogs.get_template()) self.assertIn('Test Description', pod.catalogs.get_template()) # Verify localized extract. pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'meta': { 'title@': 'Test Title', 'description@': 'Test Description', }, 'localization': { 'locales': [ 'de', ], }, }) pod.catalogs.extract(localized=True) self.assertIn('Test Title', pod.catalogs.get('de'))
def _test_deploy(self, repo_url): pod = testing.create_pod() pod.write_yaml( '/podspec.yaml', { 'deployments': { 'git': { 'destination': 'git', 'repo': repo_url, 'branch': 'gh-pages', }, }, }) pod.write_yaml('/content/pages/_blueprint.yaml', {}) pod.write_yaml('/content/pages/page.yaml', { '$path': '/{base}/', '$view': '/views/base.html', }) pod.write_file('/views/base.html', str(random.randint(0, 999))) deployment = pod.get_deployment('git') paths = [] for rendered_doc in deployment.dump(pod): paths.append(rendered_doc.path) repo = utils.get_git_repo(pod.root) stats_obj = stats.Stats(pod, paths=paths) deployment.deploy(deployment.dump(pod), stats=stats_obj, repo=repo, confirm=False, test=False)
def test_toc(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'markdown': { 'extensions': [{ 'kind': 'toc', }], } }) pod.write_yaml('/content/pages/_blueprint.yaml', { '$view': '/views/base.html', '$path': '/{base}/' }) pod.write_file('/content/pages/test.md', textwrap.dedent( """\ [TOC] # H1 ## H2 ### H3 ## H2 A """)) pod.write_file('/views/base.html', '{{doc.html|safe}}') pod.router.add_all() result = testing.render_path(pod, '/test/') toc_sentinel = '<div class="toc">' toclink_sentinel = '<a class="toclink"' title_sentinel = '<span class="toctitle">toc-title</span>' para_sentinel = '¶' sep_sentinel = 'h2_a' h2_sentinel = '<h2' self.assertIn(toc_sentinel, result) self.assertNotIn(title_sentinel, result) self.assertNotIn(toclink_sentinel, result) self.assertNotIn(sep_sentinel, result) self.assertNotIn(para_sentinel, result) self.assertIn(h2_sentinel, result) pod.write_yaml('/podspec.yaml', { 'markdown': { 'extensions': [{ 'kind': 'toc', 'title': 'toc-title', 'baselevel': 3, 'anchorlink': True, 'permalink': True, 'separator': '_' }], } }) pod = pods.Pod(pod.root) pod.router.add_all() result = testing.render_path(pod, '/test/') self.assertIn(title_sentinel, result) self.assertNotIn(h2_sentinel, result) self.assertIn(toclink_sentinel, result) self.assertIn(sep_sentinel, result) self.assertIn(para_sentinel, result)
def test_valid_locales(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'localization': { 'locales': [ 'de', 'fr', ] } }) pod.write_yaml('/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', '$localization': { 'path': '/{locale}/{base}/', } }) pod.write_file('/content/pages/page.yaml', '---\n' 'foo: bar\n' '---\n' '$locale: ja\n' 'foo: bar') doc = pod.get_doc('/content/pages/page.yaml') self.assertRaises(documents.BadLocalesError, lambda: doc.locales)
def test_owns_doc_at_path(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_yaml('/content/pages/_blueprint.yaml', {}) pod.write_yaml('/content/pages/page.yaml', {}) pod.write_yaml('/content/pages/owned/page.yaml', {}) pod.write_yaml('/content/pages/owned/deeper/page.yaml', {}) pod.write_yaml('/content/pages/sub/_blueprint.yaml', {}) pod.write_yaml('/content/pages/sub/page.yaml', {}) pod.write_yaml('/content/pages/sub/owned/page.yaml', {}) pod.write_yaml('/content/pages/sub/sub/_blueprint.yaml', {}) pod.write_yaml('/content/pages/sub/sub/page.yaml', {}) col = pod.get_collection('/content/pages') self.assertTrue(col._owns_doc_at_path('/content/pages/page.yaml')) self.assertTrue( col._owns_doc_at_path('/content/pages/owned/page.yaml')) self.assertTrue( col._owns_doc_at_path('/content/pages/owned/deeper/page.yaml')) self.assertFalse(col._owns_doc_at_path('/content/pages/sub/page.yaml')) self.assertFalse( col._owns_doc_at_path('/content/pages/sub/owned/page.yaml')) sub_col = pod.get_collection('/content/pages/sub') self.assertTrue( sub_col._owns_doc_at_path('/content/pages/sub/page.yaml')) self.assertTrue( sub_col._owns_doc_at_path('/content/pages/sub/owned/page.yaml')) self.assertFalse( sub_col._owns_doc_at_path('/content/pages/sub/sub/page.yaml'))
def test_dump_static_files_without_extension(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'static_dirs': [{ 'static_dir': '/source/media/', 'serve_at': '/static/', }], }) pod.write_yaml('/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', }) pod.write_yaml('/content/pages/foo.yaml', { '$title': 'Foo', }) pod.write_file('/source/media/file.txt', 'file') pod.write_file('/source/media/extensionless', 'file') pod.write_file('/views/base.html', '{{doc.html|safe}}') pod.router.add_all() # Verify dump appends suffix. expected = [ '/foo/index.html', '/static/file.txt', '/static/extensionless', ] paths = [] for rendered_doc in pod.dump(): paths.append(rendered_doc.path) self.assertItemsEqual(expected, paths)
def test_key_types(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) fields = { '$title@': 'Title', '$view': '/views/base.html', '$path': '/{base}/', } pod.write_yaml('/content/pages/_blueprint.yaml', fields) fields = { 0: True, 'key@': 'value', } pod.write_yaml('/content/pages/index.yaml', fields) pod.catalogs.extract() template = pod.catalogs.get_template() # Verify 'value' is added. self.assertIn('value', template) # Verify untagged non-sring isn't added. self.assertNotIn(True, template) # Verify tagged string in blueprint is added. self.assertIn('Title', template)
def test_sitemap_enabled(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'sitemap': { 'enabled': True, }, }) pod.write_yaml('/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', }) pod.write_yaml('/content/pages/foo.yaml', { '$title': 'Foo', }) pod.write_yaml('/content/pages/bar.yaml', { '$title': 'Bar', '$sitemap': { 'enabled': False, }, }) controller, params = pod.match('/sitemap.xml') content = controller.render(params) # Verify $sitemap:enabled = false. self.assertIn('/foo/', content) self.assertNotIn('/bar/', content)
def test_get_edit_url(self): pod = testing.create_pod() path = '/content/pages/home.yaml' pod.write_yaml(path, {}) # Verify Google Sheets URLs. fields = { 'preprocessors': [{ 'kind': 'google_sheets', 'path': path, 'id': '012345', 'gid': '987654', }], } pod.write_yaml('/podspec.yaml', fields) doc = pod.get_doc(path) preprocessor = pod.list_preprocessors()[0] self.assertEqual('https://docs.google.com/spreadsheets/d/012345/edit#gid=987654', preprocessor.get_edit_url(doc)) # Verify Google Docs URLs. fields = { 'preprocessors': [{ 'kind': 'google_docs', 'path': path, 'id': '012345', }], } pod.write_yaml('/podspec.yaml', fields) pod = pods.Pod(pod.root) # Reset pod.list_preprocessors. preprocessor = pod.list_preprocessors()[0] self.assertEqual('https://docs.google.com/document/d/012345/edit', preprocessor.get_edit_url(doc))
def test_gettext_format(self): """Verify that the gettext formatting works.""" pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'localization': { 'default_locale': 'en', 'locales': [ 'en', 'es', ], }, }) pod.write_file('/views/format.html', '{{_(doc.foo, bar="1", foo="2")}}') fields = { 'path': '/{locale}/{base}/', 'localization': { 'path': '/{locale}/{base}/', }, } pod.write_yaml('/content/testing/_blueprint.yaml', fields) pod.write_yaml('/content/testing/format.yaml', { '$view': '/views/format.html', 'foo': 'bar {bar} foo {foo}', 'foo@es': 'foo {foo} bar {bar}', }) pod.router.add_doc( pod.get_doc('/content/testing/format.yaml')) pod.router.add_doc( pod.get_doc('/content/testing/format.yaml', locale='es')) self.assertIn('bar 1 foo 2', self._render_path(pod, '/en/format/')) self.assertIn('foo 2 bar 1', self._render_path(pod, '/es/format/'))
def test_run(self): pod = testing.create_pod() fields = { 'preprocessors': [{ 'name': 'blogger', 'kind': 'blogger', 'blog_id': '4154157974596966834', 'collection': '/content/posts/', 'markdown': True, 'authenticated': False, 'inject': True, }], } pod.write_yaml('/podspec.yaml', fields) fields = { '$path': '/{date}/{slug}/', '$view': '/views/base.html', } pod.write_yaml('/content/posts/_blueprint.yaml', fields) content = '{{doc.html|safe}}' pod.write_file('/views/base.html', content) # Weak test to verify preprocessor runs. pod.preprocess(['blogger']) # Verify inject. collection = pod.get_collection('/content/posts') doc = collection.docs()[0] preprocessor = pod.list_preprocessors()[0] preprocessor.inject(doc)
def test_gettext_format_entities(self): """Verify that the gettext formatting works with entities.""" pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_file( '/views/format-old.html', '{{_(\'Hello %(name)s\', name=\'<strong class="awesome">Alice</strong>\')}}' ) pod.write_file( '/views/format-new.html', '{{_(\'Hello {name}\', name=\'<strong class="awesome">Alice</strong>\')}}' ) pod.write_yaml('/content/testing/_blueprint.yaml', { 'path': '/{base}/', }) pod.write_yaml('/content/testing/format-old.yaml', { '$view': '/views/format-old.html', }) pod.write_yaml('/content/testing/format-new.yaml', { '$view': '/views/format-new.html', }) pod.router.add_doc(pod.get_doc('/content/testing/format-old.yaml')) pod.router.add_doc(pod.get_doc('/content/testing/format-new.yaml')) self.assertIn('Hello <strong class="awesome">Alice</strong>', self._render_path(pod, '/format-old/')) self.assertIn('Hello <strong class="awesome">Alice</strong>', self._render_path(pod, '/format-new/'))
def _test_deploy(self, repo_url): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'deployments': { 'git': { 'destination': 'git', 'repo': repo_url, 'branch': 'gh-pages', }, }, }) pod.write_yaml('/content/pages/_blueprint.yaml', {}) pod.write_yaml('/content/pages/page.yaml', { '$path': '/{base}/', '$view': '/views/base.html', }) pod.write_file('/views/base.html', str(random.randint(0, 999))) deployment = pod.get_deployment('git') paths = [] for rendered_doc in deployment.dump(pod): paths.append(rendered_doc.path) repo = utils.get_git_repo(pod.root) stats_obj = stats.Stats(pod, paths=paths) deployment.deploy(deployment.dump(pod), stats=stats_obj, repo=repo, confirm=False, test=False)
def test_recursive_yaml(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_yaml('/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/{base}.html', '$localization': { 'default_locale': 'en', 'locales': ['de', 'en'], } }) pod.write_file('/content/pages/foo.yaml', textwrap.dedent( """\ bar: !g.doc /content/pages/bar.yaml """)) pod.write_file('/content/pages/bar.yaml', textwrap.dedent( """\ foo: !g.doc /content/pages/foo.yaml """)) foo_doc = pod.get_doc('/content/pages/foo.yaml', locale='de') bar_doc = pod.get_doc('/content/pages/bar.yaml', locale='de') self.assertEqual(bar_doc, foo_doc.bar) self.assertEqual(bar_doc, foo_doc.bar.foo.bar) self.assertEqual('de', foo_doc.bar.locale) self.assertEqual(foo_doc, bar_doc.foo) self.assertEqual(foo_doc, bar_doc.foo.bar.foo) self.assertEqual('de', bar_doc.foo.locale) foo_doc = pod.get_doc('/content/pages/foo.yaml', locale='en') bar_doc = pod.get_doc('/content/pages/bar.yaml', locale='en') self.assertEqual(bar_doc, foo_doc.bar) self.assertEqual(bar_doc, foo_doc.bar.foo.bar) self.assertEqual('en', foo_doc.bar.locale) self.assertEqual(foo_doc, bar_doc.foo) self.assertEqual(foo_doc, bar_doc.foo.bar.foo) self.assertEqual('en', bar_doc.foo.locale)
def test_fields(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) fields = { 'path': '/{base}/', 'view': '/views/base.html', 'user_field': 'foo', } pod.write_yaml('/content/collection/_blueprint.yaml', fields) collection = pod.get_collection('collection') self.assertEqual(collection.user_field, 'foo') self.assertRaises(AttributeError, lambda: collection.bad_field) # Verify backwards-compatible builtin behavior. fields = { '$path': '/{base}/', '$view': '/views/base.html', } pod.write_yaml('/content/test/_blueprint.yaml', fields) pod.write_yaml('/content/test/file.yaml', {}) doc = pod.get_doc('/content/test/file.yaml') self.assertEqual('/file/', doc.get_serving_path()) fields = { 'path': '/old/{base}/', 'view': '/views/base.html', } pod.write_yaml('/content/old/_blueprint.yaml', fields) pod.write_yaml('/content/old/file.yaml', {}) doc = pod.get_doc('/content/old/file.yaml') self.assertEqual('/old/file/', doc.get_serving_path())
def test_dump_static_files_without_extension(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'static_dirs': [{ 'static_dir': '/source/media/', 'serve_at': '/static/', }], }) pod.write_yaml('/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', }) pod.write_yaml('/content/pages/foo.yaml', { '$title': 'Foo', }) pod.write_file('/source/media/file.txt', 'file') pod.write_file('/source/media/extensionless', 'file') pod.write_file('/views/base.html', '{{doc.html|safe}}') pod.router.add_all(use_cache=False) # Verify dump appends suffix. expected = sorted([ '/foo/index.html', '/static/file.txt', '/static/extensionless', ]) paths = [] for rendered_doc in pod.dump(): paths.append(rendered_doc.path) self.assertEqual(expected, sorted(paths))
def test_docs_with_localization(self): pod = testing.create_pod() fields = { 'localization': { 'default_locale': 'en', 'locales': [ 'de', 'fr', 'it', ] } } pod.write_yaml('/podspec.yaml', fields) fields = { '$view': '/views/base.html', '$path': '/{base}/', 'localization': { 'path': '/{locale}/{base}/', } } pod.write_yaml('/content/pages/_blueprint.yaml', fields) pod.write_yaml('/content/pages/foo.yaml', {}) pod.write_yaml('/content/pages/bar.yaml', {}) pod.write_yaml('/content/pages/baz.yaml', {}) pod.write_yaml('/content/pages/[email protected]', {}) collection = pod.get_collection('pages') self.assertEqual(3, len(collection.docs(locale='en'))) self.assertEqual(3, len(collection.docs(locale='de')))
def test_utf8(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'markdown': { 'extensions': [{ 'kind': 'toc', }], } }) pod.write_yaml('/content/pages/_blueprint.yaml', { '$view': '/views/base.html', '$path': '/{base}/' }) pod.write_file('/content/pages/test.md', textwrap.dedent( """\ # Did you see the rocket launch? # 로켓 발사를 봤어? """)) pod.write_file('/views/base.html', '{{doc.html|safe}}') controller, params = pod.match('/test/') result = controller.render(params) header = '<h1 id="did-you-see-the-rocket-launch?">Did you see the rocket launch?</h1>' self.assertIn(header, result) header = u'<h1 id="로켓-발사를-봤어?">로켓 발사를 봤어?</h1>' self.assertIn(header, result)
def test_override_parts(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_yaml( '/content/pages/_blueprint.yaml', { '$view': '/views/base.html', '$localization': { 'default_locale': 'en_US', 'locales': [ 'en_US', 'ja_JP', ], }, }) pod.write_file( '/content/pages/page.yaml', textwrap.dedent("""\ --- $title: "title-base" $path: / $view: /views/pages/home.html ctas: subtitle@: Description 1. $localization: path: /intl/{locale}/ --- $locale: ja_JP $title@: "title-ja" """)) doc = pod.get_doc('/content/pages/page.yaml') self.assertEqual('title-base', doc.title) doc = pod.get_doc('/content/pages/page.yaml', locale='ja_JP') self.assertEqual('title-ja', doc.title)
def test_create_doc(self): pod = testing.create_pod() fields = { 'localization': { 'default_locale': 'en', 'locales': [ 'de', ] } } pod.write_yaml('/podspec.yaml', fields) fields = { '$view': '/views/base.html', '$path': '/{base}/', 'localization': { 'path': '/{locale}/{base}/', } } pod.write_yaml('/content/pages/_blueprint.yaml', fields) pod_collection = pod.get_collection('pages') pod_collection.create_doc('/content/pages/foo.yaml', { 'testing': 'bananas', }) doc = pod.get_doc('/content/pages/foo.yaml') self.assertEqual('bananas', doc.testing)
def test_gettext_format(self): """Verify that the gettext formatting works.""" pod = testing.create_pod() pod.write_yaml( '/podspec.yaml', { 'localization': { 'default_locale': 'en', 'locales': [ 'en', 'es', ], }, }) pod.write_file('/views/format.html', '{{_(doc.foo, bar="1", foo="2")}}') fields = { 'path': '/{locale}/{base}/', 'localization': { 'path': '/{locale}/{base}/', }, } pod.write_yaml('/content/testing/_blueprint.yaml', fields) pod.write_yaml( '/content/testing/format.yaml', { '$view': '/views/format.html', 'foo': 'bar {bar} foo {foo}', 'foo@es': 'foo {foo} bar {bar}', }) pod.router.add_doc(pod.get_doc('/content/testing/format.yaml')) pod.router.add_doc( pod.get_doc('/content/testing/format.yaml', locale='es')) self.assertIn('bar 1 foo 2', self._render_path(pod, '/en/format/')) self.assertIn('foo 2 bar 1', self._render_path(pod, '/es/format/'))
def test_get_edit_url(self): pod = testing.create_pod() path = '/content/pages/home.yaml' pod.write_yaml(path, {}) # Verify Google Sheets URLs. fields = { 'preprocessors': [{ 'kind': 'google_sheets', 'path': path, 'id': '012345', 'gid': '987654', }], } pod.write_yaml('/podspec.yaml', fields) doc = pod.get_doc(path) preprocessor = pod.list_preprocessors()[0] self.assertEqual( 'https://docs.google.com/spreadsheets/d/012345/edit#gid=987654', preprocessor.get_edit_url(doc)) # Verify Google Docs URLs. fields = { 'preprocessors': [{ 'kind': 'google_docs', 'path': path, 'id': '012345', }], } pod.write_yaml('/podspec.yaml', fields) pod = pods.Pod(pod.root) # Reset pod.list_preprocessors. preprocessor = pod.list_preprocessors()[0] self.assertEqual('https://docs.google.com/document/d/012345/edit', preprocessor.get_edit_url(doc))
def test_noclasses(self): pod = testing.create_pod() fields = { 'markdown': { 'extensions': [{ 'kind': 'sourcecode', }], } } pod.write_yaml('/podspec.yaml', fields) fields = {'$view': '/views/base.html', '$path': '/{base}/'} pod.write_yaml('/content/pages/_blueprint.yaml', fields) content = """ [sourcecode:html] <div class="test"> Hello World </div> [/sourcecode] """ pod.write_file('/content/pages/test.md', content) content = '{{doc.html|safe}}' pod.write_file('/views/base.html', content) pod.router.add_all(use_cache=False) result = testing.render_path(pod, '/test/') style_sentinel = 'style="background: #f8f8f8"' self.assertIn(style_sentinel, result) # Verify no language. content = """ [sourcecode] <div class="test"> Hello World </div> [/sourcecode] """ pod.write_file('/content/pages/test.md', content) content = '{{doc.html|safe}}' pod.write_file('/views/base.html', content) pod.router.add_all(use_cache=False) result = testing.render_path(pod, '/test/') style_sentinel = 'style="background: #f8f8f8"' self.assertIn(style_sentinel, result) fields = { 'markdown': { 'extensions': [{ 'kind': 'sourcecode', 'highlighter': 'plain', 'classes': True, }], } } pod.write_yaml('/podspec.yaml', fields) pod = pods.Pod(pod.root) pod.router.add_all(use_cache=False) result = testing.render_path(pod, '/test/') code_sentinel = '<div class="code"><pre>' self.assertIn(code_sentinel, result)
def test_dependency_nesting_jinja(self): # Verify that dependencies work for nested documents. pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'localization': { 'default_locale': 'en', 'locales': [ 'de', 'en', ], } }) pod.write_yaml( '/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', '$localization': { 'path': '/{locale}/{base}/' }, }) pod.write_file('/content/pages/page.yaml', 'partial: !g.doc /content/partials/partial.yaml') pod.write_yaml('/content/partials/_blueprint.yaml', {}) pod.write_yaml('/content/partials/partial.yaml', {}) pod.write_yaml('/content/partials/[email protected]', {}) pod.write_file( '/views/base.html', '{}{} {}'.format( '{{doc.locale}}', '{% for partial in g.docs(\'partials\') %} {{partial.locale}}{% endfor %}', '{{g.doc(\'/content/partials/partial.yaml\').locale}}', ), ) pod.router.add_all() content = testing.render_path(pod, '/page/') self.assertEqual('en en en', content) dependents = pod.podcache.dependency_graph.get_dependents( '/content/partials/partial.yaml') self.assertEqual( set([ '/content/partials/partial.yaml', '/content/pages/page.yaml', ]), dependents) content = testing.render_path(pod, '/de/page/') self.assertEqual('de de de', content) dependents = pod.podcache.dependency_graph.get_dependents( '/content/partials/[email protected]') self.assertEqual( set([ '/content/partials/[email protected]', '/content/pages/page.yaml', ]), dependents)
def test_extract_autocomments(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'localization': { 'extract': { 'localized': True, }, }, }) pod.write_yaml( '/content/pages/_blueprint.yaml', { '$title@': 'Collection Title', '$localization': { 'locales': [ 'de_DE', 'en_US', ], }, }) pod.write_yaml('/content/pages/page.yaml', { '$title@': 'Page Title', '$title@#': 'Page Title Comment', }) pod.write_yaml( '/content/pages/about.yaml', { '$title@': 'About Title', 'items@#': 'Items comment', 'items@': [ 'one', 'two', 'three', ], 'dict': { 'key@#': 'object key comment', 'key@': 'object key', }, }) pod.catalogs.extract() de_catalog = pod.catalogs.get('de_DE') # Extracted comment for string. self.assertIn('Page Title', de_catalog) message = de_catalog.get('Page Title') self.assertEqual('Page Title Comment', message.auto_comments[0]) # Extracted comments for list items. items = ['one', 'two', 'three'] for item in items: self.assertIn(item, de_catalog) message = de_catalog.get(item) self.assertEqual('Items comment', message.auto_comments[0]) # Extracted comment for dict. self.assertIn('object key', de_catalog) message = de_catalog.get('object key') self.assertEqual('object key comment', message.auto_comments[0])
def test_view_format(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_yaml('/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/{base}.html', }) pod.write_yaml('/content/pages/page.yaml', {}) doc = pod.get_doc('/content/pages/page.yaml') self.assertEqual('/views/page.html', doc.view)
def test_locale_override(self): pod = testing.create_pod() pod.write_yaml( '/podspec.yaml', { 'localization': { 'default_locale': 'en', 'locales': [ 'de', 'fr', 'it', ] } }) pod.write_yaml( '/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', '$localization': { 'path': '/{locale}/{base}/', }, }) pod.write_yaml( '/content/pages/a.yaml', { '$view': '/views/base.html', '$view@fr': '/views/base-fr.html', 'qaz': 'qux', 'qaz@fr': 'qux-fr', 'qaz@de': 'qux-de', 'qaz@fr': 'qux-fr', 'foo': 'bar-base', 'foo@en': 'bar-en', 'foo@de': 'bar-de', 'foo@fr': 'bar-fr', 'nested': { 'nested': 'nested-base', 'nested@fr': 'nested-fr', }, }) doc = pod.get_doc('/content/pages/a.yaml') self.assertEqual('en', doc.locale) self.assertEqual('bar-en', doc.foo) self.assertEqual('qux', doc.qaz) de_doc = doc.localize('de') self.assertEqual('bar-de', de_doc.foo) self.assertEqual('/views/base.html', de_doc.view) self.assertEqual('nested-base', de_doc.nested['nested']) self.assertEqual('qux-de', de_doc.qaz) fr_doc = doc.localize('fr') self.assertEqual('bar-fr', fr_doc.foo) self.assertEqual('/views/base-fr.html', fr_doc.view) self.assertEqual('nested-fr', fr_doc.nested['nested']) self.assertEqual('qux-fr', fr_doc.qaz) it_doc = doc.localize('it') self.assertEqual('bar-base', it_doc.foo) self.assertEqual('qux', it_doc.qaz)
def test_inherit(self): """Test that local specific front matter inherits from upstream docs.""" pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_file('/content/pages/foo@en_us.yaml', textwrap.dedent("""\ $title: HTML EN-US Page foo: three foobar: foo_3: test 3 """)) pod.write_file('/content/pages/[email protected]', textwrap.dedent("""\ $title: HTML EN Page foo: two bar: true foobar: foo_2: test 2 """)) pod.write_file('/content/pages/foo.yaml', textwrap.dedent("""\ $title: HTML Page foo: one foobar: foo_1: test 1 """)) doc = pod.get_doc('/content/pages/foo@en_us.yaml') front_matter = doc.format.front_matter data = front_matter.data self.assertEqual('HTML EN-US Page', data['$title']) self.assertEqual('three', data['foo']) self.assertEqual(True, data['bar']) self.assertDictEqual({ 'foo_3': 'test 3', 'foo_2': 'test 2', 'foo_1': 'test 1', }, data['foobar']) doc = pod.get_doc('/content/pages/[email protected]') front_matter = doc.format.front_matter data = front_matter.data self.assertEqual('HTML EN Page', data['$title']) self.assertEqual('two', data['foo']) self.assertEqual(True, data['bar']) self.assertDictEqual({ 'foo_2': 'test 2', 'foo_1': 'test 1', }, data['foobar']) doc = pod.get_doc('/content/pages/foo.yaml') front_matter = doc.format.front_matter data = front_matter.data self.assertEqual('HTML Page', data['$title']) self.assertEqual('one', data['foo']) self.assertDictEqual({ 'foo_1': 'test 1', }, data['foobar'])
def test_order(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_yaml('/content/col-a/_blueprint.yaml', {'$order': 2}) pod.write_yaml('/content/col-b/_blueprint.yaml', {'$order': 1}) pod.write_yaml('/content/col-c/_blueprint.yaml', {}) collection_objs = pod.list_collections() expected_sorted = ['col-b', 'col-a', 'col-c'] collection_objs.sort(key=lambda col: col.order) self.assertEqual( expected_sorted, [col.basename for col in collection_objs])
def test_audit(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_yaml('/content/pages/_blueprint.yaml', {}) pod.write_yaml('/content/pages/page.yaml', { 'title': 'Untagged string', 'subtitle@': 'Tagged string', }) untagged_strings, _ = pod.catalogs.extract(audit=True) expected = [('/content/pages/page.yaml', 'Untagged string')] self.assertEqual(expected, untagged_strings)
def test_dependency_nesting_jinja(self): # Verify that dependencies work for nested documents. pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'localization': { 'default_locale': 'en', 'locales': [ 'de', 'en', ], } }) pod.write_yaml('/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', '$localization': { 'path': '/{locale}/{base}/' }, }) pod.write_file('/content/pages/page.yaml', 'partial: !g.doc /content/partials/partial.yaml') pod.write_yaml('/content/partials/_blueprint.yaml', {}) pod.write_yaml('/content/partials/partial.yaml', {}) pod.write_yaml('/content/partials/[email protected]', {}) pod.write_file( '/views/base.html', '{}{} {}'.format( '{{doc.locale}}', '{% for partial in g.docs(\'partials\') %} {{partial.locale}}{% endfor %}', '{{g.doc(\'/content/partials/partial.yaml\').locale}}', ), ) controller, params = pod.match('/page/') content = controller.render(params) self.assertEqual('en en en', content) dependents = pod.podcache.dependency_graph.get_dependents( '/content/partials/partial.yaml') self.assertEqual(set([ '/content/partials/partial.yaml', '/content/pages/page.yaml', ]), dependents) controller, params = pod.match('/de/page/') content = controller.render(params) self.assertEqual('de de de', content) dependents = pod.podcache.dependency_graph.get_dependents( '/content/partials/[email protected]') self.assertEqual(set([ '/content/partials/[email protected]', '/content/pages/page.yaml', ]), dependents)
def test_extract_autocomments(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'localization': { 'extract': { 'localized': True, }, }, }) pod.write_yaml('/content/pages/_blueprint.yaml', { '$title@': 'Collection Title', '$localization': { 'locales': [ 'de_DE', 'en_US', ], }, }) pod.write_yaml('/content/pages/page.yaml', { '$title@': 'Page Title', '$title@#': 'Page Title Comment', }) pod.write_yaml('/content/pages/about.yaml', { '$title@': 'About Title', 'items@#': 'Items comment', 'items@': [ 'one', 'two', 'three', ], 'dict': { 'key@#': 'object key comment', 'key@': 'object key', }, }) pod.catalogs.extract() de_catalog = pod.catalogs.get('de_DE') # Extracted comment for string. self.assertIn('Page Title', de_catalog) message = de_catalog.get('Page Title') self.assertEqual('Page Title Comment', message.auto_comments[0]) # Extracted comments for list items. items = ['one', 'two', 'three'] for item in items: self.assertIn(item, de_catalog) message = de_catalog.get(item) self.assertEqual('Items comment', message.auto_comments[0]) # Extracted comment for dict. self.assertIn('object key', de_catalog) message = de_catalog.get('object key') self.assertEqual('object key comment', message.auto_comments[0])
def test_localization_fallback(self): # Verify locales aren't clobbered when no localized path is specified. pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'localization': { 'default_locale': 'en', 'locales': [ 'de', 'en', ], } }) pod.write_yaml('/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', }) pod.write_yaml('/content/pages/page.yaml', {}) pod.write_file('/views/base.html', '{{doc.locale}}') self.assertRaises(routes.DuplicatePathsError, pod.match, '/page/') pod.write_yaml( '/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', '$localization': None, }) pod.routes.reset_cache() controller, params = pod.match('/page/') content = controller.render(params) self.assertEqual('en', content) # Verify paths aren't clobbered by the default locale. pod.write_yaml( '/content/pages/page.yaml', { '$path': '/{locale}/{base}/', '$view': '/views/base.html', '$localization': { 'default_locale': 'de', 'path': '/{locale}/{base}/', 'locales': [ 'en', 'de', ], }, }) pod.podcache.reset() pod.routes.reset_cache() controller, params = pod.match('/de/page/') content = controller.render(params) self.assertEqual('de', content) paths = pod.routes.list_concrete_paths() expected = ['/en/page/', '/de/page/'] self.assertEqual(expected, paths)
def test_categories(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) fields = { 'path': '/{base}/', 'view': '/views/base.html', 'categories': [ 'Category1', 'Category2', 'Category3', 'Category4', 'Category5', ], } # Verify default behavior. pod.write_yaml('/content/collection/_blueprint.yaml', fields) pod.write_yaml('/content/collection/doc1.yaml', { '$category': 'Category1', }) pod.write_yaml('/content/collection/doc2.yaml', { '$category': 'Category1', }) pod.write_yaml('/content/collection/doc3.yaml', { '$category': 'Category2', }) result = tags.categories(collection='collection', _pod=pod) result = [item[0] for item in result] expected = ['Category1', 'Category2'] self.assertEqual(expected, result) # Verify localized behavior. fields.update({ 'localization': { 'locales': [ 'en', ], } }) pod.write_yaml('/content/collection/_blueprint.yaml', fields) pod.write_yaml('/content/collection/[email protected]', { '$category': 'Category3', }) pod.write_yaml('/content/collection/[email protected]', { '$category': 'Category3', }) pod.write_yaml('/content/collection/[email protected]', { '$category': 'Category6', }) result = tags.categories(collection='collection', locale='de', _pod=pod) result = [item[0] for item in result] expected = ['Category3', 'Category6',] self.assertEqual(expected, result)
def test_localization_fallback(self): # Verify locales aren't clobbered when no localized path is specified. pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'localization': { 'default_locale': 'en', 'locales': [ 'de', 'en', ], } }) pod.write_yaml('/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', }) pod.write_yaml('/content/pages/page.yaml', {}) pod.write_file('/views/base.html', '{{doc.locale}}') pod.write_yaml( '/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', '$localization': None, }) pod.router.add_all() content = testing.render_path(pod, '/page/') self.assertEqual('en', content) # Verify paths aren't clobbered by the default locale. pod.write_yaml( '/content/pages/page.yaml', { '$path': '/{locale}/{base}/', '$view': '/views/base.html', '$localization': { 'default_locale': 'de', 'path': '/{locale}/{base}/', 'locales': [ 'en', 'de', ], }, }) pod.podcache.reset() pod.router.routes.reset() pod.router.add_all() content = testing.render_path(pod, '/de/page/') self.assertEqual('de', content) paths = list(pod.router.routes.paths) expected = ['/de/page/', '/en/page/'] self.assertEqual(expected, paths)
def test_yaml_dump(self): """Test if the yaml representer is working correctly.""" pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_yaml('/content/pages/page.yaml', {}) doc = pod.get_doc('/content/pages/page.yaml') input_obj = {'doc': doc} expected = textwrap.dedent("""\ doc: !g.doc '/content/pages/page.yaml' """) self.assertEqual(expected, utils.dump_yaml(input_obj))
def test_subcollection_paths(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'localization': { 'default_locale': 'en', 'locales': [ 'de', 'en', ] } }) pod.write_yaml( '/content/pages/_blueprint.yaml', { '$view': '/views/base.html', '$path': '/{base}/', '$localization': { 'path': '/{locale}/{base}/', } }) pod.write_yaml('/content/pages/page.yaml', { '$title': 'Page', }) pod.write_yaml( '/content/pages/sub/_blueprint.yaml', { '$view': '/views/base.html', '$path': '/sub/{base}/', '$localization': { 'path': '/sub/{locale}/{base}/', } }) pod.write_yaml('/content/pages/sub/page.yaml', { '$title': 'Sub Page', }) # Verify subcollections are included in pod.list_collections. collection_objs = pod.list_collections() pages = pod.get_collection('pages') sub = pod.get_collection('pages/sub') expected = [pages, sub] self.assertEqual(expected, collection_objs) # Verify subcollection docs are not included in collection.docs. expected = [ pod.get_doc('/content/pages/page.yaml'), pod.get_doc('/content/pages/page.yaml', locale='de'), ] docs = pages.docs(recursive=False) self.assertEqual(expected, list(docs)) paths = pod.routes.list_concrete_paths() expected = ['/sub/page/', '/de/page/', '/sub/de/page/', '/page/'] self.assertEqual(expected, paths)
def test_locale_override(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'localization': { 'default_locale': 'en', 'locales': [ 'de', 'fr', 'it', ] } }) pod.write_yaml('/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', '$localization': { 'path': '/{locale}/{base}/', }, }) pod.write_yaml('/content/pages/a.yaml', { '$view': '/views/base.html', '$view@fr': '/views/base-fr.html', 'qaz': 'qux', 'qaz@fr': 'qux-fr', 'qaz@de': 'qux-de', 'qaz@fr': 'qux-fr', 'foo': 'bar-base', 'foo@en': 'bar-en', 'foo@de': 'bar-de', 'foo@fr': 'bar-fr', 'nested': { 'nested': 'nested-base', 'nested@fr': 'nested-fr', }, }) doc = pod.get_doc('/content/pages/a.yaml') self.assertEqual('en', doc.locale) self.assertEqual('bar-en', doc.foo) self.assertEqual('qux', doc.qaz) de_doc = doc.localize('de') self.assertEqual('bar-de', de_doc.foo) self.assertEqual('/views/base.html', de_doc.view) self.assertEqual('nested-base', de_doc.nested['nested']) self.assertEqual('qux-de', de_doc.qaz) fr_doc = doc.localize('fr') self.assertEqual('bar-fr', fr_doc.foo) self.assertEqual('/views/base-fr.html', fr_doc.view) self.assertEqual('nested-fr', fr_doc.nested['nested']) self.assertEqual('qux-fr', fr_doc.qaz) it_doc = doc.localize('it') self.assertEqual('bar-base', it_doc.foo) self.assertEqual('qux', it_doc.qaz)
def test_dependency_nesting_yaml(self): # Verify that dependencies work for nested documents. pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'localization': { 'default_locale': 'en', 'locales': [ 'de', 'en', ], } }) pod.write_yaml( '/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', '$localization': { 'path': '/{locale}/{base}/' }, }) pod.write_file('/content/pages/page.yaml', 'partial: !g.doc /content/partials/partial.yaml') pod.write_yaml('/content/partials/_blueprint.yaml', {}) pod.write_yaml('/content/partials/partial.yaml', {}) pod.write_yaml('/content/partials/[email protected]', {}) pod.write_file('/views/base.html', '{{doc.locale}} {{doc.partial.locale}}') controller, params = pod.match('/page/') content = controller.render(params) self.assertEqual('en en', content) dependents = pod.podcache.dependency_graph.get_dependents( '/content/partials/partial.yaml') self.assertEqual( set([ '/content/partials/partial.yaml', '/content/pages/page.yaml', ]), dependents) controller, params = pod.match('/de/page/') content = controller.render(params) self.assertEqual('de de', content) dependents = pod.podcache.dependency_graph.get_dependents( '/content/partials/[email protected]') self.assertEqual( set([ '/content/partials/[email protected]', '/content/pages/page.yaml', ]), dependents)
def test_list(self): collection.Collection.list(self.pod) # Verify empty collection behavior. pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_yaml('/content/col1/_blueprint.yaml', {}) pod.write_yaml('/content/col2/doc1.yaml', {}) collection_objs = collection.Collection.list(pod) self.assertEqual(['col1'], [col.basename for col in collection_objs]) pod.write_yaml('/content/col2/_blueprint.yaml', {}) collection_objs = collection.Collection.list(pod) self.assertEqual(['col1', 'col2'], [col.basename for col in collection_objs])
def test_title(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_yaml('/content/pages/_blueprint.yaml', { '$title@': 'Base Title', '$titles': { 'nav@': 'Nav Title', }, }) col = pod.get_collection('pages') self.assertEqual('Base Title', col.title) self.assertEqual('Base Title', col.titles('none')) self.assertEqual('Nav Title', col.titles('nav'))
def test_localization_fallback(self): # Verify locales aren't clobbered when no localized path is specified. pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'localization': { 'default_locale': 'en', 'locales': [ 'de', 'en', ], } }) pod.write_yaml('/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', }) pod.write_yaml('/content/pages/page.yaml', {}) pod.write_file('/views/base.html', '{{doc.locale}}') self.assertRaises(routes.DuplicatePathsError, pod.match, '/page/') pod.write_yaml('/content/pages/_blueprint.yaml', { '$path': '/{base}/', '$view': '/views/base.html', '$localization': None, }) pod.routes.reset_cache() controller, params = pod.match('/page/') content = controller.render(params) self.assertEqual('en', content) # Verify paths aren't clobbered by the default locale. pod.write_yaml('/content/pages/page.yaml', { '$path': '/{locale}/{base}/', '$view': '/views/base.html', '$localization': { 'default_locale': 'de', 'path': '/{locale}/{base}/', 'locales': [ 'en', 'de', ], }, }) pod.podcache.reset() pod.routes.reset_cache() controller, params = pod.match('/de/page/') content = controller.render(params) self.assertEqual('de', content) paths = pod.routes.list_concrete_paths() expected = ['/en/page/', '/de/page/'] self.assertEqual(expected, paths)
def test_subcollection_paths(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', { 'localization': { 'default_locale': 'en', 'locales': [ 'de', 'en', ] } }) pod.write_yaml('/content/pages/_blueprint.yaml', { '$view': '/views/base.html', '$path': '/{base}/', '$localization': { 'path': '/{locale}/{base}/', } }) pod.write_yaml('/content/pages/page.yaml', { '$title': 'Page', }) pod.write_yaml('/content/pages/sub/_blueprint.yaml', { '$view': '/views/base.html', '$path': '/sub/{base}/', '$localization': { 'path': '/sub/{locale}/{base}/', } }) pod.write_yaml('/content/pages/sub/page.yaml', { '$title': 'Sub Page', }) # Verify subcollections are included in pod.list_collections. collection_objs = pod.list_collections() pages = pod.get_collection('pages') sub = pod.get_collection('pages/sub') expected = [pages, sub] self.assertEqual(expected, collection_objs) # Verify subcollection docs are not included in collection.docs. expected = [ pod.get_doc('/content/pages/page.yaml'), pod.get_doc('/content/pages/page.yaml', locale='de'), ] docs = pages.docs(recursive=False) self.assertEqual(expected, list(docs)) paths = pod.routes.list_concrete_paths() expected= ['/sub/page/', '/de/page/', '/sub/de/page/', '/page/'] self.assertEqual(expected, paths)
def test_nested_collections(self): # While it was undefined behavior before, projects relied on the # ability to place documents in subfolders inside collections without # explicit _blueprint.yaml files inside those folders. Verify that # paths are still generated for those documents. pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_file('/views/base.html', '') fields = { '$path': '/{base}/', '$view': '/views/base.html', } pod.write_yaml('/content/collection/_blueprint.yaml', fields) pod.write_yaml('/content/collection/root.yaml', {}) pod.write_yaml('/content/collection/folder/folder.yaml', {}) pod.write_yaml('/content/collection/folder/subfolder/subfolder.yaml', {}) pod.write_yaml( '/content/collection/folder2/subfolder2/subfolder2.yaml', {}) pod.router.add_all(use_cache=False) expected = [ '/root/', '/folder/', '/subfolder/', '/subfolder2/', ] self.assertEqual(sorted(expected), sorted(list(pod.router.routes.paths))) # Blueprints one level deep. fields = { '$path': '/subfolder-one-level/{base}/', '$view': '/views/base.html', } pod.write_yaml('/content/collection/folder/_blueprint.yaml', fields) doc = pod.get_doc('/content/collection/folder/folder.yaml') self.assertEqual('/subfolder-one-level/folder/', doc.get_serving_path()) # Blueprints two levels deep. fields = { '$path': '/subfolder-two-levels/{base}/', '$view': '/views/base.html', } pod.write_yaml('/content/collection/folder/subfolder/_blueprint.yaml', fields) doc = pod.get_doc( '/content/collection/folder/subfolder/subfolder.yaml') self.assertEqual('/subfolder-two-levels/subfolder/', doc.get_serving_path())
def test_yaml_dump(self): """Test if the yaml representer is working correctly.""" pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_yaml('/content/pages/page.yaml', {}) doc = pod.get_doc('/content/pages/page.yaml') input_obj = { 'doc': doc } expected = textwrap.dedent( """\ doc: !g.doc '/content/pages/page.yaml' """) self.assertEqual(expected, utils.dump_yaml(input_obj))
def test_render_error(self): pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_file('/views/base.html', '{{doc.tulip()}}') fields = { 'path': '/{base}/', 'view': '/views/base.html', } pod.write_yaml('/content/collection/_blueprint.yaml', fields) pod.write_file('/content/collection/test.yaml', '') # Verify fails with correct error. controller, params = pod.match('/test/') with self.assertRaises(errors.BuildError): controller.render(params)
def test_nested_collections(self): # While it was undefined behavior before, projects relied on the # ability to place documents in subfolders inside collections without # explicit _blueprint.yaml files inside those folders. Verify that # paths are still generated for those documents. pod = testing.create_pod() pod.write_yaml('/podspec.yaml', {}) pod.write_file('/views/base.html', '') fields = { '$path': '/{base}/', '$view': '/views/base.html', } pod.write_yaml('/content/collection/_blueprint.yaml', fields) pod.write_yaml('/content/collection/root.yaml', {}) pod.write_yaml('/content/collection/folder/folder.yaml', {}) pod.write_yaml( '/content/collection/folder/subfolder/subfolder.yaml', {}) pod.write_yaml( '/content/collection/folder2/subfolder2/subfolder2.yaml', {}) pod.router.add_all() expected = [ '/root/', '/folder/', '/subfolder/', '/subfolder2/', ] self.assertItemsEqual(expected, list(pod.router.routes.paths)) # Blueprints one level deep. fields = { '$path': '/subfolder-one-level/{base}/', '$view': '/views/base.html', } pod.write_yaml('/content/collection/folder/_blueprint.yaml', fields) doc = pod.get_doc('/content/collection/folder/folder.yaml') self.assertEqual('/subfolder-one-level/folder/', doc.get_serving_path()) # Blueprints two levels deep. fields = { '$path': '/subfolder-two-levels/{base}/', '$view': '/views/base.html', } pod.write_yaml( '/content/collection/folder/subfolder/_blueprint.yaml', fields) doc = pod.get_doc( '/content/collection/folder/subfolder/subfolder.yaml') self.assertEqual( '/subfolder-two-levels/subfolder/', doc.get_serving_path())