~ubuntu-branches/ubuntu/maverick/python-django/maverick

« back to all changes in this revision

Viewing changes to tests/regressiontests/views/tests/static.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2009-07-29 11:26:28 UTC
  • mfrom: (1.1.8 upstream) (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090729112628-pg09ino8sz0sj21t
Tags: 1.1-1
* New upstream release.
* Merge from experimental:
  - Ship FastCGI initscript and /etc/default file in python-django's examples
    directory (Closes: #538863)
  - Drop "05_10539-sphinx06-compatibility.diff"; it has been applied
    upstream.
  - Bump Standards-Version to 3.8.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from os import path
 
2
 
 
3
from django.test import TestCase
 
4
from regressiontests.views.urls import media_dir
 
5
 
 
6
class StaticTests(TestCase):
 
7
    """Tests django views in django/views/static.py"""
 
8
 
 
9
    def test_serve(self):
 
10
        "The static view can serve static media"
 
11
        media_files = ['file.txt',]
 
12
        for filename in media_files:
 
13
            response = self.client.get('/views/site_media/%s' % filename)
 
14
            file = open(path.join(media_dir, filename))
 
15
            self.assertEquals(file.read(), response.content)
 
16
            self.assertEquals(len(response.content), int(response['Content-Length']))
 
17
 
 
18
    def test_unknown_mime_type(self):
 
19
        response = self.client.get('/views/site_media/file.unknown')
 
20
        self.assertEquals('application/octet-stream', response['Content-Type'])
 
21
 
 
22
    def test_copes_with_empty_path_component(self):
 
23
        file_name = 'file.txt'
 
24
        response = self.client.get('/views/site_media//%s' % file_name)
 
25
        file = open(path.join(media_dir, file_name))
 
26
        self.assertEquals(file.read(), response.content)
 
27