From: Ben Darnell Date: Sat, 7 Jul 2018 14:12:35 +0000 (-0400) Subject: maint: Delete appengine test scripts X-Git-Tag: v6.0.0b1~48^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70ab73bb7bdf3b8a0f3ee5ed9a782044bf5790db;p=thirdparty%2Ftornado.git maint: Delete appengine test scripts --- diff --git a/demos/appengine/README b/demos/appengine/README deleted file mode 100644 index e4aead670..000000000 --- a/demos/appengine/README +++ /dev/null @@ -1,48 +0,0 @@ -Running the Tornado AppEngine example -===================================== -This example is designed to run in Google AppEngine, so there are a couple -of steps to get it running. You can download the Google AppEngine Python -development environment at http://code.google.com/appengine/downloads.html. - -1. Link or copy the tornado code directory into this directory: - - ln -s ../../tornado tornado - - AppEngine doesn't use the Python modules installed on this machine. - You need to have the 'tornado' module copied or linked for AppEngine - to find it. - -3. Install and run dev_appserver - - If you don't already have the App Engine SDK, download it from - http://code.google.com/appengine/downloads.html - - To start the tornado demo, run the dev server on this directory: - - dev_appserver.py . - -4. Visit http://localhost:8080/ in your browser - - If you sign in as an administrator, you will be able to create and - edit blog posts. If you sign in as anybody else, you will only see - the existing blog posts. - - -If you want to deploy the blog in production: - -1. Register a new appengine application and put its id in app.yaml - - First register a new application at http://appengine.google.com/. - Then edit app.yaml in this directory and change the "application" - setting from "tornado-appenginge" to your new application id. - -2. Deploy to App Engine - - If you registered an application id, you can now upload your new - Tornado blog by running this command: - - appcfg update . - - After that, visit application_id.appspot.com, where application_id - is the application you registered. - diff --git a/demos/appengine/app.yaml b/demos/appengine/app.yaml deleted file mode 100644 index c90cecdba..000000000 --- a/demos/appengine/app.yaml +++ /dev/null @@ -1,12 +0,0 @@ -application: tornado-appengine -version: 2 -runtime: python27 -api_version: 1 -threadsafe: yes - -handlers: -- url: /static/ - static_dir: static - -- url: /.* - script: blog.application diff --git a/demos/appengine/blog.py b/demos/appengine/blog.py deleted file mode 100644 index e2b2ef504..000000000 --- a/demos/appengine/blog.py +++ /dev/null @@ -1,166 +0,0 @@ -# -# Copyright 2009 Facebook -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import functools -import os.path -import re -import tornado.escape -import tornado.web -import tornado.wsgi -import unicodedata - -from google.appengine.api import users -from google.appengine.ext import db - - -class Entry(db.Model): - """A single blog entry.""" - author = db.UserProperty() - title = db.StringProperty(required=True) - slug = db.StringProperty(required=True) - body_source = db.TextProperty(required=True) - html = db.TextProperty(required=True) - published = db.DateTimeProperty(auto_now_add=True) - updated = db.DateTimeProperty(auto_now=True) - - -def administrator(method): - """Decorate with this method to restrict to site admins.""" - @functools.wraps(method) - def wrapper(self, *args, **kwargs): - if not self.current_user: - if self.request.method == "GET": - self.redirect(self.get_login_url()) - return - raise tornado.web.HTTPError(403) - elif not self.current_user.administrator: - if self.request.method == "GET": - self.redirect("/") - return - raise tornado.web.HTTPError(403) - else: - return method(self, *args, **kwargs) - return wrapper - - -class BaseHandler(tornado.web.RequestHandler): - """Implements Google Accounts authentication methods.""" - def get_current_user(self): - user = users.get_current_user() - if user: - user.administrator = users.is_current_user_admin() - return user - - def get_login_url(self): - return users.create_login_url(self.request.uri) - - def get_template_namespace(self): - # Let the templates access the users module to generate login URLs - ns = super(BaseHandler, self).get_template_namespace() - ns['users'] = users - return ns - - -class HomeHandler(BaseHandler): - def get(self): - entries = db.Query(Entry).order('-published').fetch(limit=5) - if not entries: - if not self.current_user or self.current_user.administrator: - self.redirect("/compose") - return - self.render("home.html", entries=entries) - - -class EntryHandler(BaseHandler): - def get(self, slug): - entry = db.Query(Entry).filter("slug =", slug).get() - if not entry: - raise tornado.web.HTTPError(404) - self.render("entry.html", entry=entry) - - -class ArchiveHandler(BaseHandler): - def get(self): - entries = db.Query(Entry).order('-published') - self.render("archive.html", entries=entries) - - -class FeedHandler(BaseHandler): - def get(self): - entries = db.Query(Entry).order('-published').fetch(limit=10) - self.set_header("Content-Type", "application/atom+xml") - self.render("feed.xml", entries=entries) - - -class ComposeHandler(BaseHandler): - @administrator - def get(self): - key = self.get_argument("key", None) - entry = Entry.get(key) if key else None - self.render("compose.html", entry=entry) - - @administrator - def post(self): - key = self.get_argument("key", None) - if key: - entry = Entry.get(key) - entry.title = self.get_argument("title") - entry.body_source = self.get_argument("body_source") - entry.html = tornado.escape.linkify( - self.get_argument("body_source")) - else: - title = self.get_argument("title") - slug = unicodedata.normalize("NFKD", title).encode( - "ascii", "ignore") - slug = re.sub(r"[^\w]+", " ", slug) - slug = "-".join(slug.lower().strip().split()) - if not slug: - slug = "entry" - while True: - existing = db.Query(Entry).filter("slug =", slug).get() - if not existing or str(existing.key()) == key: - break - slug += "-2" - entry = Entry( - author=self.current_user, - title=title, - slug=slug, - body_source=self.get_argument("body_source"), - html=tornado.escape.linkify(self.get_argument("body_source")), - ) - entry.put() - self.redirect("/entry/" + entry.slug) - - -class EntryModule(tornado.web.UIModule): - def render(self, entry): - return self.render_string("modules/entry.html", entry=entry) - - -settings = { - "blog_title": u"Tornado Blog", - "template_path": os.path.join(os.path.dirname(__file__), "templates"), - "ui_modules": {"Entry": EntryModule}, - "xsrf_cookies": True, -} -application = tornado.web.Application([ - (r"/", HomeHandler), - (r"/archive", ArchiveHandler), - (r"/feed", FeedHandler), - (r"/entry/([^/]+)", EntryHandler), - (r"/compose", ComposeHandler), -], **settings) - -application = tornado.wsgi.WSGIAdapter(application) diff --git a/demos/appengine/static/blog.css b/demos/appengine/static/blog.css deleted file mode 100644 index 3ebef875e..000000000 --- a/demos/appengine/static/blog.css +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2009 Facebook - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -body { - background: white; - color: black; - margin: 15px; - margin-top: 0; -} - -body, -input, -textarea { - font-family: Georgia, serif; - font-size: 12pt; -} - -table { - border-collapse: collapse; - border: 0; -} - -td { - border: 0; - padding: 0; -} - -h1, -h2, -h3, -h4 { - font-family: "Helvetica Nue", Helvetica, Arial, sans-serif; - margin: 0; -} - -h1 { - font-size: 20pt; -} - -pre, -code { - font-family: monospace; - color: #060; -} - -pre { - margin-left: 1em; - padding-left: 1em; - border-left: 1px solid silver; - line-height: 14pt; -} - -a, -a code { - color: #00c; -} - -#body { - max-width: 800px; - margin: auto; -} - -#header { - background-color: #3b5998; - padding: 5px; - padding-left: 10px; - padding-right: 10px; - margin-bottom: 1em; -} - -#header, -#header a { - color: white; -} - -#header h1 a { - text-decoration: none; -} - -#footer, -#content { - margin-left: 10px; - margin-right: 10px; -} - -#footer { - margin-top: 3em; -} - -.entry h1 a { - color: black; - text-decoration: none; -} - -.entry { - margin-bottom: 2em; -} - -.entry .date { - margin-top: 3px; -} - -.entry p { - margin: 0; - margin-bottom: 1em; -} - -.entry .body { - margin-top: 1em; - line-height: 16pt; -} - -.compose td { - vertical-align: middle; - padding-bottom: 5px; -} - -.compose td.field { - padding-right: 10px; -} - -.compose .title, -.compose .submit { - font-family: "Helvetica Nue", Helvetica, Arial, sans-serif; - font-weight: bold; -} - -.compose .title { - font-size: 20pt; -} - -.compose .title, -.compose .body_source { - width: 100%; -} - -.compose .body_source { - height: 500px; - line-height: 16pt; -} diff --git a/demos/appengine/templates/archive.html b/demos/appengine/templates/archive.html deleted file mode 100644 index d50146497..000000000 --- a/demos/appengine/templates/archive.html +++ /dev/null @@ -1,31 +0,0 @@ -{% extends "base.html" %} - -{% block head %} - -{% end %} - -{% block body %} - -{% end %} diff --git a/demos/appengine/templates/base.html b/demos/appengine/templates/base.html deleted file mode 100644 index 7ea0efa9f..000000000 --- a/demos/appengine/templates/base.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - {{ handler.settings["blog_title"] }} - - - {% block head %}{% end %} - - -
- -
{% block body %}{% end %}
-
- {% block bottom %}{% end %} - - diff --git a/demos/appengine/templates/compose.html b/demos/appengine/templates/compose.html deleted file mode 100644 index 39045e039..000000000 --- a/demos/appengine/templates/compose.html +++ /dev/null @@ -1,40 +0,0 @@ -{% extends "base.html" %} - -{% block body %} -
-
-
-
- -  {{ _("Cancel") }} -
- {% if entry %} - - {% end %} - {% module xsrf_form_html() %} -
-{% end %} - -{% block bottom %} - - -{% end %} diff --git a/demos/appengine/templates/entry.html b/demos/appengine/templates/entry.html deleted file mode 100644 index f3f495b49..000000000 --- a/demos/appengine/templates/entry.html +++ /dev/null @@ -1,5 +0,0 @@ -{% extends "base.html" %} - -{% block body %} - {% module Entry(entry) %} -{% end %} diff --git a/demos/appengine/templates/feed.xml b/demos/appengine/templates/feed.xml deleted file mode 100644 index a98826c8d..000000000 --- a/demos/appengine/templates/feed.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - {% set date_format = "%Y-%m-%dT%H:%M:%SZ" %} - {{ handler.settings["blog_title"] }} - {% if len(entries) > 0 %} - {{ max(e.updated for e in entries).strftime(date_format) }} - {% else %} - {{ datetime.datetime.utcnow().strftime(date_format) }} - {% end %} - http://{{ request.host }}/ - - - {{ handler.settings["blog_title"] }} - {% for entry in entries %} - - http://{{ request.host }}/entry/{{ entry.slug }} - {{ entry.title }} - - {{ entry.updated.strftime(date_format) }} - {{ entry.published.strftime(date_format) }} - -
{% raw entry.html %}
-
-
- {% end %} -
diff --git a/demos/appengine/templates/home.html b/demos/appengine/templates/home.html deleted file mode 100644 index 8e990ca56..000000000 --- a/demos/appengine/templates/home.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "base.html" %} - -{% block body %} - {% for entry in entries %} - {% module Entry(entry) %} - {% end %} -
{{ _("Archive") }}
-{% end %} diff --git a/demos/appengine/templates/modules/entry.html b/demos/appengine/templates/modules/entry.html deleted file mode 100644 index 201c04118..000000000 --- a/demos/appengine/templates/modules/entry.html +++ /dev/null @@ -1,8 +0,0 @@ -
-

{{ entry.title }}

-
{{ locale.format_date(entry.published, full_format=True, shorter=True) }}
-
{% raw entry.html %}
- {% if current_user and current_user.administrator %} - - {% end %} -
diff --git a/maint/test/appengine/README b/maint/test/appengine/README deleted file mode 100644 index 8d534f28d..000000000 --- a/maint/test/appengine/README +++ /dev/null @@ -1,8 +0,0 @@ -Unit test support for app engine. Currently very limited as most of -our tests depend on direct network access, but these tests ensure that the -modules that are supposed to work on app engine don't depend on any -forbidden modules. - -The code lives in maint/appengine/common, but should be run from the py25 -or py27 subdirectories (which contain an app.yaml and a bunch of symlinks). -runtests.py is the entry point; cgi_runtests.py is used internally. diff --git a/maint/test/appengine/common/cgi_runtests.py b/maint/test/appengine/common/cgi_runtests.py deleted file mode 100755 index f28aa6ca0..000000000 --- a/maint/test/appengine/common/cgi_runtests.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -from __future__ import absolute_import, division, print_function - -import sys -import unittest - -# Most of our tests depend on IOLoop, which is not usable on app engine. -# Run the tests that work, and check that everything else is at least -# importable (via tornado.test.import_test) -TEST_MODULES = [ - 'tornado.httputil.doctests', - 'tornado.iostream.doctests', - 'tornado.util.doctests', - #'tornado.test.auth_test', - #'tornado.test.concurrent_test', - #'tornado.test.curl_httpclient_test', - 'tornado.test.escape_test', - #'tornado.test.gen_test', - #'tornado.test.httpclient_test', - #'tornado.test.httpserver_test', - 'tornado.test.httputil_test', - 'tornado.test.import_test', - #'tornado.test.ioloop_test', - #'tornado.test.iostream_test', - 'tornado.test.locale_test', - #'tornado.test.netutil_test', - #'tornado.test.log_test', - 'tornado.test.options_test', - #'tornado.test.process_test', - #'tornado.test.simple_httpclient_test', - #'tornado.test.stack_context_test', - 'tornado.test.template_test', - #'tornado.test.testing_test', - #'tornado.test.twisted_test', - 'tornado.test.util_test', - #'tornado.test.web_test', - #'tornado.test.websocket_test', - #'tornado.test.wsgi_test', -] - - -def all(): - return unittest.defaultTestLoader.loadTestsFromNames(TEST_MODULES) - - -def main(): - print("Content-Type: text/plain\r\n\r\n", end="") - - try: - unittest.main(defaultTest='all', argv=sys.argv[:1]) - except SystemExit as e: - if e.code == 0: - print("PASS") - else: - raise - - -if __name__ == '__main__': - main() diff --git a/maint/test/appengine/common/runtests.py b/maint/test/appengine/common/runtests.py deleted file mode 100755 index ca7abe119..000000000 --- a/maint/test/appengine/common/runtests.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -from __future__ import absolute_import, division, print_function - -import contextlib -import errno -import os -import random -import signal -import socket -import subprocess -import sys -import time -import urllib2 - -try: - xrange -except NameError: - xrange = range - -if __name__ == "__main__": - tornado_root = os.path.abspath(os.path.join(os.path.dirname(__file__), - '../../..')) - # dev_appserver doesn't seem to set SO_REUSEADDR - port = random.randrange(10000, 11000) - # does dev_appserver.py ever live anywhere but /usr/local/bin? - proc = subprocess.Popen([sys.executable, - "/usr/local/bin/dev_appserver.py", - os.path.dirname(os.path.abspath(__file__)), - "--port=%d" % port, - "--skip_sdk_update_check", - ], - cwd=tornado_root) - - try: - for i in xrange(50): - with contextlib.closing(socket.socket()) as sock: - err = sock.connect_ex(('localhost', port)) - if err == 0: - break - elif err != errno.ECONNREFUSED: - raise Exception("Got unexpected socket error %d" % err) - time.sleep(0.1) - else: - raise Exception("Server didn't start listening") - - resp = urllib2.urlopen("http://localhost:%d/" % port) - print(resp.read()) - finally: - # dev_appserver sometimes ignores SIGTERM (especially on 2.5), - # so try a few times to kill it. - for sig in [signal.SIGTERM, signal.SIGTERM, signal.SIGKILL]: - os.kill(proc.pid, sig) - res = os.waitpid(proc.pid, os.WNOHANG) - if res != (0, 0): - break - time.sleep(0.1) - else: - os.waitpid(proc.pid, 0) diff --git a/maint/test/appengine/py27/app.yaml b/maint/test/appengine/py27/app.yaml deleted file mode 100644 index e5dea072d..000000000 --- a/maint/test/appengine/py27/app.yaml +++ /dev/null @@ -1,9 +0,0 @@ -application: tornado-tests-appengine27 -version: 1 -runtime: python27 -threadsafe: false -api_version: 1 - -handlers: -- url: / - script: cgi_runtests.py \ No newline at end of file diff --git a/maint/test/appengine/py27/cgi_runtests.py b/maint/test/appengine/py27/cgi_runtests.py deleted file mode 120000 index a9fc90e99..000000000 --- a/maint/test/appengine/py27/cgi_runtests.py +++ /dev/null @@ -1 +0,0 @@ -../common/cgi_runtests.py \ No newline at end of file diff --git a/maint/test/appengine/py27/runtests.py b/maint/test/appengine/py27/runtests.py deleted file mode 120000 index 2cce26b0f..000000000 --- a/maint/test/appengine/py27/runtests.py +++ /dev/null @@ -1 +0,0 @@ -../common/runtests.py \ No newline at end of file diff --git a/maint/test/appengine/py27/tornado b/maint/test/appengine/py27/tornado deleted file mode 120000 index d4f6cc317..000000000 --- a/maint/test/appengine/py27/tornado +++ /dev/null @@ -1 +0,0 @@ -../../../../tornado \ No newline at end of file diff --git a/maint/test/appengine/setup.py b/maint/test/appengine/setup.py deleted file mode 100644 index 5d2d3141d..000000000 --- a/maint/test/appengine/setup.py +++ /dev/null @@ -1,4 +0,0 @@ -# Dummy setup file to make tox happy. In the appengine world things aren't -# installed through setup.py -import distutils.core -distutils.core.setup() diff --git a/maint/test/appengine/tox.ini b/maint/test/appengine/tox.ini deleted file mode 100644 index ca7a861ae..000000000 --- a/maint/test/appengine/tox.ini +++ /dev/null @@ -1,15 +0,0 @@ -# App Engine tests require the SDK to be installed separately. -# Version 1.6.1 or newer is required (older versions don't work when -# python is run from a virtualenv) -# -# These are currently excluded from the main tox.ini because their -# logs are spammy and they're a little flaky. -[tox] -envlist = py27-appengine - -[testenv] -changedir = {toxworkdir} - -[testenv:py27-appengine] -basepython = python2.7 -commands = python {toxinidir}/py27/runtests.py {posargs:}