~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to tests/modeltests/fixtures_model_package/models/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2010-10-12 11:34:35 UTC
  • mfrom: (1.1.12 upstream) (29.1.1 maverick-security)
  • Revision ID: james.westby@ubuntu.com-20101012113435-yy57c8tx6g9anf3e
Tags: 1.2.3-1ubuntu0.1
* SECURITY UPDATE: XSS in CSRF protections. New upstream release
  - CVE-2010-3082
* debian/patches/01_disable_url_verify_regression_tests.diff:
  - updated to disable another test that fails without internet connection
  - patch based on work by Kai Kasurinen and Krzysztof Klimonda
* debian/control: don't Build-Depends on locales-all, which doesn't exist
  in maverick

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
        app_label = 'fixtures_model_package'
13
13
        ordering = ('-pub_date', 'headline')
14
14
 
15
 
__test__ = {'API_TESTS': """
16
 
>>> from django.core import management
17
 
>>> from django.db.models import get_app
18
 
 
19
 
# Reset the database representation of this app.
20
 
# This will return the database to a clean initial state.
21
 
>>> management.call_command('flush', verbosity=0, interactive=False)
22
 
 
23
 
# Syncdb introduces 1 initial data object from initial_data.json.
24
 
>>> Article.objects.all()
25
 
[<Article: Python program becomes self aware>]
26
 
 
27
 
# Load fixture 1. Single JSON file, with two objects.
28
 
>>> management.call_command('loaddata', 'fixture1.json', verbosity=0)
29
 
>>> Article.objects.all()
30
 
[<Article: Time to reform copyright>, <Article: Poker has no place on ESPN>, <Article: Python program becomes self aware>]
31
 
 
32
 
# Load fixture 2. JSON file imported by default. Overwrites some existing objects
33
 
>>> management.call_command('loaddata', 'fixture2.json', verbosity=0)
34
 
>>> Article.objects.all()
35
 
[<Article: Django conquers world!>, <Article: Copyright is fine the way it is>, <Article: Poker has no place on ESPN>, <Article: Python program becomes self aware>]
36
 
 
37
 
# Load a fixture that doesn't exist
38
 
>>> management.call_command('loaddata', 'unknown.json', verbosity=0)
39
 
 
40
 
# object list is unaffected
41
 
>>> Article.objects.all()
42
 
[<Article: Django conquers world!>, <Article: Copyright is fine the way it is>, <Article: Poker has no place on ESPN>, <Article: Python program becomes self aware>]
43
 
"""}
44
 
 
45
 
 
46
 
from django.test import TestCase
47
 
 
48
 
class SampleTestCase(TestCase):
49
 
    fixtures = ['fixture1.json', 'fixture2.json']
50
 
 
51
 
    def testClassFixtures(self):
52
 
        "Check that test case has installed 4 fixture objects"
53
 
        self.assertEqual(Article.objects.count(), 4)
54
 
        self.assertEquals(str(Article.objects.all()), "[<Article: Django conquers world!>, <Article: Copyright is fine the way it is>, <Article: Poker has no place on ESPN>, <Article: Python program becomes self aware>]")