Exemplo n.º 1
0
 def setUp(self):
     self.dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(self.dir_path,
                         storage=storage.FileStorage,
                         use_reroute=True)
     self.batches = render_batch.RenderBatches(self.pod.render_pool,
                                               self.pod.profile)
Exemplo n.º 2
0
 def setUp(self):
     self.config = base_config.BaseConfig()
     self.config.set('gerrit', True)
     self.dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage)
     self.installer = gerrit_installer.GerritInstaller(
         self.pod, self.config)
Exemplo n.º 3
0
 def setUp(self):
     self.config = base_config.BaseConfig()
     self.config.set('gerrit', True)
     self.dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage)
     self.installer = gerrit_installer.GerritInstaller(
         self.pod, self.config)
Exemplo n.º 4
0
    def test_request(self):
        dir_path = testing.create_test_pod_dir()
        pod = pods.Pod(dir_path)
        pod.router.add_all(use_cache=False)

        # When serving a pod, should 200.
        app = main.create_wsgi_app(pod, 'localhost', 8080)
        request = webob.Request.blank('/')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)

        # Verify 404 is sent for page not found.
        request = webob.Request.blank('/dummy/page/')
        response = request.get_response(app)
        self.assertEqual(404, response.status_int)

        # Verify 206 for partial content.
        headers = {'Range': 'bytes=0-4'}
        request = webob.Request.blank('/public/file.txt', headers=headers)
        response = request.get_response(app)
        self.assertEqual(206, response.status_int)
        self.assertEqual('bytes 0-4/13', response.headers['Content-Range'])
        self.assertEqual(b'Hello', response.body)

        headers = {'Range': 'bytes=5-13'}
        request = webob.Request.blank('/public/file.txt', headers=headers)
        response = request.get_response(app)
        self.assertEqual('bytes 5-12/13', response.headers['Content-Range'])
        self.assertEqual(b' World!\n', response.body)

        # Verify full response when headers omitted.
        request = webob.Request.blank('/public/file.txt')
        response = request.get_response(app)
        self.assertEqual(b'Hello World!\n', response.body)

        # Verify 304.
        url_path = '/public/file.txt'
        matched = pod.router.routes.match(url_path)
        controller = pod.router.get_render_controller(url_path,
                                                      matched.value,
                                                      params=matched.params)
        response_headers = controller.get_http_headers()
        headers = {'If-None-Match': response_headers['Last-Modified']}
        request = webob.Request.blank(url_path, headers=headers)
        response = request.get_response(app)
        self.assertEqual(304, response.status_int)
        self.assertEqual(b'', response.body)

        response = request.get_response(app)
        self.assertEqual(304, response.status_int)
        self.assertEqual(b'', response.body)

        # Verify sitemap on server.
        path = '/root/sitemap.xml'
        request = webob.Request.blank(path)
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
        self.assertEqual('application/xml', response.headers['Content-Type'])
Exemplo n.º 5
0
    def test_request(self):
        dir_path = testing.create_test_pod_dir()
        pod = pods.Pod(dir_path)
        pod.router.add_all()

        # When serving a pod, should 200.
        app = main.create_wsgi_app(pod, 'localhost', 8080)
        request = webapp2.Request.blank('/')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)

        # Verify 404 is sent for page not found.
        request = webapp2.Request.blank('/dummy/page/')
        response = request.get_response(app)
        self.assertEqual(404, response.status_int)

        # Verify 206 for partial content.
        headers = {'Range': 'bytes=0-4'}
        request = webapp2.Request.blank('/public/file.txt', headers=headers)
        response = request.get_response(app)
        self.assertEqual(206, response.status_int)
        self.assertEqual('bytes 0-4/13', response.headers['Content-Range'])
        self.assertEqual('Hello', response.body)

        headers = {'Range': 'bytes=5-13'}
        request = webapp2.Request.blank('/public/file.txt', headers=headers)
        response = request.get_response(app)
        self.assertEqual('bytes 5-12/13', response.headers['Content-Range'])
        self.assertEqual(' World!\n', response.body)

        # Verify full response when headers omitted.
        request = webapp2.Request.blank('/public/file.txt')
        response = request.get_response(app)
        self.assertEqual('Hello World!\n', response.body)

        # Verify 304.
        url_path = '/public/file.txt'
        matched = pod.router.routes.match(url_path)
        controller = pod.router.get_render_controller(
            url_path, matched.value, params=matched.params)
        response_headers = controller.get_http_headers()
        headers = {'If-None-Match': response_headers['Last-Modified']}
        request = webapp2.Request.blank(url_path, headers=headers)
        response = request.get_response(app)
        self.assertEqual(304, response.status_int)
        self.assertEqual('', response.body)

        response = request.get_response(app)
        self.assertEqual(304, response.status_int)
        self.assertEqual('', response.body)

        # Verify sitemap on server.
        path = '/root/sitemap.xml'
        request = webapp2.Request.blank(path)
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
        self.assertEqual('application/xml', response.headers['Content-Type'])
Exemplo n.º 6
0
 def test_diff(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path, storage=storage.FileStorage)
     other_catalogs = self.pod.get_catalogs('translations-diff/messages.pot')
     self.pod.catalogs.diff(other_catalogs, 'translations-diff-out')
     diffed_catalogs = self.pod.get_catalogs('translations-diff-out/messages.pot')
     de_catalog = diffed_catalogs.get('de', dir_path=diffed_catalogs.root)
     self.assertIn('About', de_catalog)
     self.assertNotIn('About us', de_catalog)
Exemplo n.º 7
0
 def test_diff(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path, storage=storage.FileStorage)
     other_catalogs = self.pod.get_catalogs(
         'translations-diff/messages.pot')
     self.pod.catalogs.diff(other_catalogs, 'translations-diff-out')
     diffed_catalogs = self.pod.get_catalogs(
         'translations-diff-out/messages.pot')
     de_catalog = diffed_catalogs.get('de', dir_path=diffed_catalogs.root)
     self.assertIn('About', de_catalog)
     self.assertNotIn('About us', de_catalog)
Exemplo n.º 8
0
    def test_request(self):
        """Test that api requests can be completed correctly."""
        dir_path = testing.create_test_pod_dir()
        pod = pods.Pod(dir_path)
        pod.router.add_all()

        # When serving a pod, should 200.
        app = main.create_wsgi_app(pod, 'localhost', 8080)
        request = webapp2.Request.blank(
            '/_grow/api/editor/content?pod_path=/content/pages/home.yaml')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
Exemplo n.º 9
0
    def test_request(self):
        self.dir_path = testing.create_test_pod_dir()
        pod = pods.Pod(self.dir_path)

        # When serving a pod, should 200.
        app = main.create_wsgi_app(pod)
        request = webapp2.Request.blank('/')
        response = request.get_response(app)
        self.assertEqual(response.status_int, 200)

        # Verify 404 is sent for blank page.
        request = webapp2.Request.blank('/dummy/page/')
        response = request.get_response(app)
        self.assertEqual(response.status_int, 404)
Exemplo n.º 10
0
    def test_editor(self):
        dir_path = testing.create_test_pod_dir()
        pod = pods.Pod(dir_path)
        pod.router.add_all()
        app = main.create_wsgi_app(pod, 'localhost', 8080)

        # Verify routes are served.
        request = webapp2.Request.blank('/_grow/editor')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
        js_sentinel = 'front_matter'
        self.assertIn(js_sentinel, response.body)

        request = webapp2.Request.blank('/_grow/ui/css/editor.min.css')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
Exemplo n.º 11
0
 def test_export_untranslated_catalogs(self):
     """Make sure that we can make catalogs from the untranslated strings."""
     dir_path = testing.create_test_pod_dir()
     pod = pods.Pod(dir_path, storage=storage.FileStorage)
     stats = translation_stats.TranslationStats()
     stats.tick(catalog.Message(
         'About',
         None,
     ), 'ga', 'en')
     self.assertEqual({
         'ga': {
             'About': 1,
         },
     }, stats.untranslated)
     untranslated_catalogs = stats.export_untranslated_catalogs(pod)
     self.assertTrue('About' in untranslated_catalogs['ga'])
Exemplo n.º 12
0
    def test_admin(self):
        dir_path = testing.create_test_pod_dir()
        pod = pods.Pod(dir_path)
        pod.router.add_all(use_cache=False)
        app = main.create_wsgi_app(pod, 'localhost', 8080)

        # Verify routes are served.
        request = webob.Request.blank('/_grow/routes')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
        js_sentinel = b'<h2>Routes</h2>'
        self.assertIn(js_sentinel, response.body)

        request = webob.Request.blank('/_grow/ui/css/admin.min.css')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
Exemplo n.º 13
0
    def test_editor(self):
        dir_path = testing.create_test_pod_dir()
        pod = pods.Pod(dir_path, use_reroute=True)
        pod.router.add_all()
        app = main.create_wsgi_app(pod, 'localhost', 8080)

        # Verify routes are served.
        request = webapp2.Request.blank('/_grow/editor')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
        js_sentinel = 'front_matter'
        self.assertIn(js_sentinel, response.body)

        request = webapp2.Request.blank('/_grow/ui/css/editor.min.css')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
Exemplo n.º 14
0
    def test_request(self):
        self.dir_path = testing.create_test_pod_dir()
        pod = pods.Pod(self.dir_path)

        # When serving a pod, should 200.
        app = main.create_wsgi_app(pod)
        request = webapp2.Request.blank('/')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)

        # Verify 404 is sent for page not found.
        request = webapp2.Request.blank('/dummy/page/')
        response = request.get_response(app)
        self.assertEqual(404, response.status_int)

        # Verify 206 for partial content.
        headers = {'Range': 'bytes=0-4'}
        request = webapp2.Request.blank('/public/file.txt', headers=headers)
        response = request.get_response(app)
        self.assertEqual(206, response.status_int)
        self.assertEqual('bytes 0-4/13', response.headers['Content-Range'])
        self.assertEqual('Hello', response.body)

        headers = {'Range': 'bytes=5-13'}
        request = webapp2.Request.blank('/public/file.txt', headers=headers)
        response = request.get_response(app)
        self.assertEqual('bytes 5-12/13', response.headers['Content-Range'])
        self.assertEqual(' World!\n', response.body)

        # Verify full response when headers omitted.
        request = webapp2.Request.blank('/public/file.txt')
        response = request.get_response(app)
        self.assertEqual('Hello World!\n', response.body)

        # Verify 304.
        url_path = '/public/file.txt'
        controller, params = pod.match(url_path)
        response_headers = controller.get_http_headers(params)
        headers = {'If-None-Match': response_headers['Last-Modified']}
        request = webapp2.Request.blank(url_path, headers=headers)
        response = request.get_response(app)
        self.assertEqual(304, response.status_int)
        self.assertEqual('', response.body)

        response = request.get_response(app)
        self.assertEqual(304, response.status_int)
        self.assertEqual('', response.body)
Exemplo n.º 15
0
    def test_ui(self):
        dir_path = testing.create_test_pod_dir()
        pod = pods.Pod(dir_path)
        app = main.create_wsgi_app(pod)

        # Verify JS and CSS are served.
        request = webapp2.Request.blank('/_grow/ui/js/ui.min.js')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
        js_sentinel = '!function'
        self.assertIn(js_sentinel, response.body)

        request = webapp2.Request.blank('/_grow/ui/css/ui.min.css')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
        css_sentinel = '#grow'
        self.assertIn(css_sentinel, response.body)
Exemplo n.º 16
0
    def test_ui(self):
        dir_path = testing.create_test_pod_dir()
        pod = pods.Pod(dir_path)
        pod.router.add_all(use_cache=False)
        app = main.create_wsgi_app(pod, 'localhost', 8080)

        # Verify JS and CSS are served.
        request = webob.Request.blank('/_grow/ui/js/ui.min.js')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
        js_sentinel = b'setAttribute("target","_blank")'
        self.assertIn(js_sentinel, response.body)

        request = webob.Request.blank('/_grow/ui/css/ui.min.css')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
        css_sentinel = b'#grow'
        self.assertIn(css_sentinel, response.body)
Exemplo n.º 17
0
 def test_export_untranslated_catalogs(self):
     """Make sure that we can make catalogs from the untranslated strings."""
     dir_path = testing.create_test_pod_dir()
     pod = pods.Pod(dir_path, storage=storage.FileStorage)
     stats = translation_stats.TranslationStats()
     stats.tick(catalog.Message(
         'About',
         None,
     ), 'ga', 'en')
     self.assertEqual(
         {
             'ga': {
                 'About': 1,
             },
         },
         stats.untranslated)
     untranslated_catalogs = stats.export_untranslated_catalogs(pod)
     self.assertTrue('About' in untranslated_catalogs['ga'])
Exemplo n.º 18
0
    def test_ui(self):
        dir_path = testing.create_test_pod_dir()
        pod = pods.Pod(dir_path, use_reroute=True)
        pod.router.add_all()
        app = main.create_wsgi_app(pod, 'localhost', 8080)

        # Verify JS and CSS are served.
        request = webapp2.Request.blank('/_grow/ui/js/ui.min.js')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
        js_sentinel = 'function(modules)'
        self.assertIn(js_sentinel, response.body)

        request = webapp2.Request.blank('/_grow/ui/css/ui.min.css')
        response = request.get_response(app)
        self.assertEqual(200, response.status_int)
        css_sentinel = '#grow'
        self.assertIn(css_sentinel, response.body)
Exemplo n.º 19
0
  def test_request(self):
    self.dir_path = testing.create_test_pod_dir()
    pod = pods.Pod(self.dir_path)

    # Verify application errors when no pod root is set.
    app = main.CreateWSGIApplication()
    request = webapp2.Request.blank('/')
    response = request.get_response(app)
    self.assertEqual(response.status_int, 500)

    # When serving a pod, should 200.
    app = main.CreateWSGIApplication(pod)
    request = webapp2.Request.blank('/')
    response = request.get_response(app)
    self.assertEqual(response.status_int, 200)

    # Verify 404 is sent for blank page.
    request = webapp2.Request.blank('/dummy/page/')
    response = request.get_response(app)
    self.assertEqual(response.status_int, 404)
Exemplo n.º 20
0
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path, storage=storage.FileStorage)
     self.pod.catalogs.compile()
Exemplo n.º 21
0
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path)
Exemplo n.º 22
0
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path, storage=storage.FileStorage)
     self.doc_cache = document_cache.DocumentCache()
Exemplo n.º 23
0
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path, storage=storage.FileStorage)
     self.pod.write_yaml('/podspec.yaml', {})
Exemplo n.º 24
0
 def setUp(self):
     self.dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage)
     self.router = grow_router.Router(self.pod)
Exemplo n.º 25
0
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path, storage=storage.FileStorage)
     self.routes_cache = routes_cache.RoutesCache()
Exemplo n.º 26
0
 def setUp(self):
   self.test_pod_dir = testing.create_test_pod_dir()
   self.runner = click_testing.CliRunner()
Exemplo n.º 27
0
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path, storage=storage.FileStorage)
     self.obj_cache = object_cache.ObjectCache()
Exemplo n.º 28
0
 def setUp(self):
   self.dir_path = testing.create_test_pod_dir()
   self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage)
Exemplo n.º 29
0
 def setUp(self):
   dir_path = testing.create_test_pod_dir()
   self.pod = pods.Pod(dir_path, storage=storage.FileStorage)
   self.pod.catalogs.compile()
Exemplo n.º 30
0
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path, storage=storage.FileStorage)
     self.obj_cache = object_cache.ObjectCache()
Exemplo n.º 31
0
 def setUp(self):
     self.test_pod_dir = testing.create_test_pod_dir()
     self.runner = click_testing.CliRunner()
Exemplo n.º 32
0
 def setUp(self):
     self.config = base_config.BaseConfig()
     self.dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage)
     self.installer = nvm_installer.NvmInstaller(self.pod, self.config)
Exemplo n.º 33
0
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path, storage=storage.FileStorage)
     super(GoogleTranslatorToolkitTestCase, self).setUp()
Exemplo n.º 34
0
 def setUp(self):
     self.dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage)
     self.installer = installer.Installer([], self.pod)
Exemplo n.º 35
0
 def setUp(self):
     self.dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage)
     self.router = grow_router.Router(self.pod)
Exemplo n.º 36
0
 def setUp(self):
     self.dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage, use_reroute=True)
     self.render = renderer.Renderer()
Exemplo n.º 37
0
 def setUp(self):
     self.config = base_config.BaseConfig()
     self.dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage)
     self.installer = bower_installer.BowerInstaller(
         self.pod, self.config)
Exemplo n.º 38
0
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path, storage=storage.FileStorage)
     self.pod.write_yaml('/podspec.yaml', {})
Exemplo n.º 39
0
 def setUp(self):
     self.config = base_config.BaseConfig()
     self.dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage)
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path, storage=storage.FileStorage)
     super(GoogleTranslatorToolkitTestCase, self).setUp()
Exemplo n.º 41
0
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path, storage=storage.FileStorage)
     self.doc_cache = document_cache.DocumentCache()
Exemplo n.º 42
0
 def setUp(self):
     self.dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage)
Exemplo n.º 43
0
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path)