Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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'])
Esempio 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'])
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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'])
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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'])
Esempio 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)
Esempio 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)
Esempio 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()
Esempio n. 21
0
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path)
Esempio 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()
Esempio 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', {})
Esempio 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)
Esempio 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()
Esempio n. 26
0
 def setUp(self):
   self.test_pod_dir = testing.create_test_pod_dir()
   self.runner = click_testing.CliRunner()
Esempio 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()
Esempio n. 28
0
 def setUp(self):
   self.dir_path = testing.create_test_pod_dir()
   self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage)
Esempio 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()
Esempio 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()
Esempio n. 31
0
 def setUp(self):
     self.test_pod_dir = testing.create_test_pod_dir()
     self.runner = click_testing.CliRunner()
Esempio 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)
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path, storage=storage.FileStorage)
     super(GoogleTranslatorToolkitTestCase, self).setUp()
Esempio 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)
Esempio 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)
Esempio 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()
Esempio 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)
Esempio 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', {})
Esempio 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()
Esempio 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()
Esempio n. 42
0
 def setUp(self):
     self.dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage)
Esempio n. 43
0
 def setUp(self):
     dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(dir_path)