Пример #1
0
 def test_format_pod_env_fingerprint(self):
     """Test env fingerprints."""
     env = _mock_env(fingerprint="ABC123")
     pod = _mock_pod(env=env)
     path_format = grow_path_format.PathFormat(pod)
     self.assertEquals('/ABC123/test',
                       path_format.format_pod('/{env.fingerprint}/test'))
Пример #2
0
 def test_format_static_root(self):
     """Test doc paths."""
     pod = _mock_pod(podspec={
         'root': 'root_path',
     })
     path_format = grow_path_format.PathFormat(pod)
     self.assertEquals('/root_path/test',
                       path_format.format_static('/{root}/test'))
Пример #3
0
 def test_format_pod_extra_slash(self):
     """Test extra slashes are removed."""
     pod = _mock_pod(podspec={
         'root': '/root_path',
     })
     path_format = grow_path_format.PathFormat(pod)
     self.assertEquals('/root_path/test',
                       path_format.format_pod('/{root}/test'))
Пример #4
0
 def test_format_doc_base(self):
     """Test doc paths with the base filename."""
     pod = _mock_pod(podspec={
         'root': 'root_path',
     })
     path_format = grow_path_format.PathFormat(pod)
     doc = _mock_doc(pod, base='doc1')
     self.assertEqual('/doc1/', path_format.format_doc(doc, '/{base}/'))
Пример #5
0
 def test_format_static_locale(self):
     """Test doc paths with locale."""
     pod = _mock_pod(podspec={
         'root': 'root_path',
     })
     path_format = grow_path_format.PathFormat(pod)
     doc = _mock_static(pod, '/{root}/test/{locale}', locale='es')
     self.assertEquals('/root_path/test/es', path_format.format_static(doc))
Пример #6
0
 def test_format_doc_root(self):
     """Test doc paths."""
     pod = _mock_pod(podspec={
         'root': 'root_path',
     })
     path_format = grow_path_format.PathFormat(pod)
     doc = _mock_doc(pod)
     self.assertEqual('/root_path/test/',
                      path_format.format_doc(doc, '/{root}/test'))
Пример #7
0
 def test_format_static_locale_params(self):
     """Test doc paths with locale and keeping params."""
     pod = _mock_pod(podspec={
         'root': 'root_path',
     })
     path_format = grow_path_format.PathFormat(pod)
     doc = _mock_static(pod, '/{root}/test/{locale}', locale='es')
     self.assertEquals('/root_path/test/:locale',
                       path_format.format_static(doc, parameterize=True))
Пример #8
0
 def test_format_pod_params(self):
     """Test params are converted."""
     pod = _mock_pod(podspec={
         'root': '/root_path',
     })
     path_format = grow_path_format.PathFormat(pod)
     self.assertEquals(
         '/root_path/test/:locale/something',
         path_format.format_pod('/{root}/test/{locale}/something',
                                parameterize=True))
Пример #9
0
 def test_format_static_fingerprint(self):
     """Test doc paths with fingerprint."""
     pod = _mock_pod(podspec={
         'root': 'root_path',
     })
     path_format = grow_path_format.PathFormat(pod)
     self.assertEqual(
         '/root_path/test/asdf',
         path_format.format_static('/{root}/test/{fingerprint}',
                                   fingerprint='asdf'))
Пример #10
0
 def test_format_doc_collection(self):
     """Test doc paths."""
     pod = _mock_pod(podspec={
         'root': 'root_path',
     })
     path_format = grow_path_format.PathFormat(pod)
     collection = _mock_collection(basename='/pages/')
     doc = _mock_doc(pod,
                     collection=collection,
                     collection_base_path='/sub/')
     self.assertEquals(
         '/root_path/sub/test/',
         path_format.format_doc(doc, '/{root}/{collection.base_path}/test'))
Пример #11
0
    def test_format_doc_base_index(self):
        """Test doc paths with the index as a base filename."""
        pod = _mock_pod(podspec={
            'root': 'root_path',
        })
        path_format = grow_path_format.PathFormat(pod)
        doc = _mock_doc(pod, base='index')
        self.assertEqual('/', path_format.format_doc(doc, '/{base}/'))
        self.assertEqual('/', path_format.format_doc(doc, '/{base}'))

        # Does not replace index when it is not the end of the path.
        self.assertEqual('/index.html',
                         path_format.format_doc(doc, '/{base}.html'))
Пример #12
0
 def path_format(self):
     """Format utility for url paths."""
     return grow_path_format.PathFormat(self)