1. pombredanne
  2. django-wsgiserver3

Commits

clee  committed 2f40797

add staticfiles work

  • Participants
  • Parent commits f31a571
  • Branches default

Comments (0)

Files changed (12)

File .hgignore

View file
  • Ignore whitespace
 dist/*
 build/*
 MANIFEST
+*.sqlite

File tests/README.rst

View file
  • Ignore whitespace
+To run these tests I would like to use something automatic like nose and twill or something
+but for now it's by hand
+
+I set up a virtualenv with django 1.3 pre installed on it, and then cd to testdjangoproject
+
+To run basic tests::
+
+  python manage.py runwsgiserver
+
+And visit http://locahost:8000/ in a browser
+
+To run ssl tests::
+
+  ./test_ssl
+
+and vist https://localhost:8443/ in a browser
+
+
+currently test_statics adds to the settings file to put in STATICFILES_ROOT
+
+
+The web page shows links to click on.
+  

File tests/requirements.txt

View file
  • Ignore whitespace
+django
+django-debug-toolbar

File tests/test_mediahandler.py

View file
  • Ignore whitespace
+# serve static files via wsgiserver and mediahandler
+
+# TODO
+# test serving a single directory
+# test performance
+# test serving multiple directories with dispatch
+# test urls that try to escape root

File tests/test_pypi

View file
  • Ignore whitespace
+# sketch test out a potential upload or an actual upload to pypi
+# requires: virtualenv, pip
+
+# create a virtualenv testenv
+# activate the enviroment
+# install $pkg:
+# pip install -e $pkgrepo
+# pip install $pkg
+# pip install -e $testprojdir
+# cd tesprojdir; python manage.py tests
+# also do visual tests

File tests/testdjangoproject/notstatic3/textfile.txt

View file
  • Ignore whitespace
+This text file is in the notstatic3 directory

File tests/testdjangoproject/settings_statics.py

View file
  • Ignore whitespace
+
+from settings import *
+STATICFILES_ROOT = os.path.join(PROJECT_ROOT, 'static')
+
+# experimental for development work it would be nice to not need to
+# run collectstatic all the time
+STATICFILES_DIRS = (
+  # 
+  # ("urlprefix", "/path/to/the/files"), # I usually have urlprefix be appname
+    os.path.join(PROJECT_ROOT, "static2"),
+    ('static3', os.path.join(PROJECT_ROOT, "notstatic3")),
+)

File tests/testdjangoproject/static/htmlfile.html

View file
  • Ignore whitespace
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+    <title>test static html file in static root</title>
+</head>
+<body>
+<h3>test static html file in static root</h3>
+</body>
+</html>

File tests/testdjangoproject/static/textfile.txt

View file
  • Ignore whitespace
+A test text file

File tests/testdjangoproject/static2/textfile.txt

View file
  • Ignore whitespace
+This textfile is in the static2 directory

File tests/testdjangoproject/templates/hello.html

View file
  • Ignore whitespace
+<html>
+  <head>
+    <title>django-wsgiserver</title>
+  </head>
+  <body><h2>hello django-wsgiserver</h2>
+ 
+    <h3>Tests</h3>
+    <ul>
+      <li> <a href="/admin/">Check the default admin css media service</a></li>
+{% if HAS_STATICFILES_URL %}
+      <li> <a href="/static/textfile.txt">/static/textfile.txt </a></li>
+      <li> <a href="/static/htmlfile.html">/static/htmlfile.txt </a></li>
+      <li> <a href="/static/../settings.py"> /static/../settings.py security test</a> should not return the settings.py file! (either forbidden or remap to another url)</li>
+      {% else %}
+      <li> Staticfiles are not being used </li>
+{% endif %}
+    </ul>
+</body>
+</html>

File tests/testdjangoproject/test_staticfiles

View file
  • Ignore whitespace
+#!/bin/sh
+python ./manage.py runwsgiserver --settings=settings_statics