Commits

Anonymous committed 2f40797

add staticfiles work

Comments (0)

Files changed (12)

 dist/*
 build/*
 MANIFEST
+*.sqlite
+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.
+  

tests/requirements.txt

+django
+django-debug-toolbar

tests/test_mediahandler.py

+# 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
+# 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

tests/testdjangoproject/notstatic3/textfile.txt

+This text file is in the notstatic3 directory

tests/testdjangoproject/settings_statics.py

+
+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")),
+)

tests/testdjangoproject/static/htmlfile.html

+<!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>

tests/testdjangoproject/static/textfile.txt

+A test text file

tests/testdjangoproject/static2/textfile.txt

+This textfile is in the static2 directory

tests/testdjangoproject/templates/hello.html

+<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>

tests/testdjangoproject/test_staticfiles

+#!/bin/sh
+python ./manage.py runwsgiserver --settings=settings_statics
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.