Commits

Mikhail Korobov committed cc8d57b

more tests

Comments (0)

Files changed (4)

test_proj/settings.py

 DATABASE_ENGINE = 'sqlite3'
 DATABASE_NAME = 'testdb.sqlite'
 SITE_ID = 1
+DEBUG = True
 
 TEMPLATE_LOADERS = (
     'django.template.loaders.filesystem.load_template_source',

test_proj/test_app/admin.py

 from django.contrib import admin
-from test_app.models import MyModel
+from test_app.models import Foo, Bar
 
-admin.site.register(MyModel)
+admin.site.register(Foo)
+admin.site.register(Bar)

test_proj/test_app/models.py

 from django.db import models
 
-class MyModel(models.Model):
+class Foo(models.Model):
+    pass
+
+class Bar(models.Model):
     pass

test_proj/test_app/tests.py

     def test_permissions(self):
         self.assertTrue(self.client.login(username='staff', password='123'))
         res = self.client.get('/admin/')
-        self.assertContains(res, 'My models')
+        self.assertContains(res, 'Foos')
+        self.assertNotContains(res, 'Bars')
         self.assertNotContains(res, 'Users')
 
         self.assertTrue(self.client.login(username='superuser', password='123'))
         self.assertContains(self.client.get('/admin/'), 'Users')
+
+    def test_app_index(self):
+        self.client.login(username='staff', password='123')
+        res = self.client.get('/admin/test_app/foo/')
+        self.assertEqual(res.status_code, 200)
+        self.assertContains(res, 'Foos')
+        self.assertNotContains(res, 'Bars')
+
+        self.client.login(username='superuser', password='123')
+        res = self.client.get('/admin/test_app/foo/')
+        self.assertContains(res, 'Foos')
+        self.assertContains(res, 'Bars')