diff -r 9995a9ec390d -r 5a49f7749349 tests/regressiontests/views/fixtures/testdata.json
a
|
b
|
|
28 | 28 | "slug": "future_article", |
29 | 29 | "date_created": "3000-01-01 21:22:23" |
30 | 30 | } |
31 | | }, |
32 | | |
| 31 | }, |
33 | 32 | { |
34 | 33 | "pk": 1, |
35 | 34 | "model": "views.author", |
36 | 35 | "fields": { |
37 | 36 | "name": "Boris" |
38 | 37 | } |
39 | | }, |
| 38 | }, |
| 39 | { |
| 40 | "pk": 2, |
| 41 | "model": "views.author", |
| 42 | "fields": { |
| 43 | "name": "Natasha" |
| 44 | } |
| 45 | }, |
| 46 | { |
| 47 | "pk": 1, |
| 48 | "model": "views.reviewedarticle", |
| 49 | "fields": { |
| 50 | "author": 1, |
| 51 | "reviewer": 2, |
| 52 | "title": "Reviewed Article" |
| 53 | } |
| 54 | }, |
40 | 55 | { |
41 | 56 | "pk": 1, |
42 | 57 | "model": "sites.site", |
… |
… |
|
44 | 59 | "domain": "testserver", |
45 | 60 | "name": "testserver" |
46 | 61 | } |
47 | | } |
| 62 | }, |
| 63 | { |
| 64 | "pk": 1, |
| 65 | "model": "auth.user", |
| 66 | "fields": { |
| 67 | "username": "root", |
| 68 | "first_name": "Super", |
| 69 | "last_name": "User", |
| 70 | "is_active": true, |
| 71 | "is_superuser": true, |
| 72 | "is_staff": true, |
| 73 | "last_login": "2007-12-13 11:49:43", |
| 74 | "groups": [], |
| 75 | "user_permissions": [], |
| 76 | "password": "sha1$3435d$f45ddc0acfa0db94de8ba06d2546d1661dffe6db", |
| 77 | "email": "root@localhost", |
| 78 | "date_joined": "2007-12-13 11:49:43" |
| 79 | } |
| 80 | } |
48 | 81 | ] |
diff -r 9995a9ec390d -r 5a49f7749349 tests/regressiontests/views/models.py
a
|
b
|
class Author(models.Model):
|
8 | 8 | class Author(models.Model): |
9 | 9 | name = models.CharField(max_length=100) |
10 | 10 | |
| 11 | class Admin: |
| 12 | pass |
| 13 | |
11 | 14 | def __unicode__(self): |
12 | 15 | return self.name |
13 | 16 | |
14 | 17 | def get_absolute_url(self): |
15 | 18 | return '/views/authors/%s/' % self.id |
16 | | |
17 | 19 | |
18 | 20 | class Article(models.Model): |
19 | 21 | title = models.CharField(max_length=100) |
… |
… |
class Article(models.Model):
|
24 | 26 | def __unicode__(self): |
25 | 27 | return self.title |
26 | 28 | |
| 29 | class ReviewedArticle(models.Model): |
| 30 | title = models.CharField(max_length=100) |
| 31 | author = models.ForeignKey(Author, related_name='authors') |
| 32 | reviewer = models.ForeignKey(Author, related_name='reviewers') |
| 33 | |
| 34 | class Admin: |
| 35 | pass |
| 36 | |
| 37 | def __unicode__(self): |
| 38 | return self.title |
diff -r 9995a9ec390d -r 5a49f7749349 tests/regressiontests/views/tests/__init__.py
a
|
b
|
from defaults import *
|
1 | 1 | from defaults import * |
2 | 2 | from i18n import * |
3 | 3 | from static import * |
4 | | from generic.date_based import * |
5 | | No newline at end of file |
| 4 | from generic.date_based import * |
| 5 | from admin import * |
| 6 | No newline at end of file |
diff -r 9995a9ec390d -r 5a49f7749349 tests/regressiontests/views/tests/admin.py
-
|
+
|
|
| 1 | from django.test import TestCase |
| 2 | |
| 3 | class AdminTests(TestCase): |
| 4 | fixtures = ['testdata.json'] |
| 5 | |
| 6 | def test_delete_stage(self): |
| 7 | "Delete stage includes all objects to be deleted" |
| 8 | self.assertTrue(self.client.login(username='root', password='password')) |
| 9 | response = self.client.get('/views/admin/views/author/2/delete/') |
| 10 | self.assertContains(response, "Reviewed Article") |
diff -r 9995a9ec390d -r 5a49f7749349 tests/regressiontests/views/urls.py
a
|
b
|
urlpatterns = patterns('',
|
44 | 44 | dict(allow_future=True, slug_field='slug', **date_based_info_dict)), |
45 | 45 | (r'^date_based/archive_month/(?P<year>\d{4})/(?P<month>\d{1,2})/$', |
46 | 46 | 'django.views.generic.date_based.archive_month', |
47 | | date_based_info_dict), |
| 47 | date_based_info_dict), |
| 48 | |
| 49 | # Admin views |
| 50 | (r'^admin/', include('django.contrib.admin.urls')), |
48 | 51 | ) |