Mikhail Korobov avatar Mikhail Korobov committed 1721273

Move user to initial data. Static file serving for ./manage testserver.

Comments (0)

Files changed (6)

test_proj/fixtures/users.json

-[
-    {
-        "pk": 1,
-        "model": "auth.user",
-        "fields": {
-            "username": "user",
-            "first_name": "",
-            "last_name": "",
-            "is_active": 1,
-            "is_superuser": 1,
-            "is_staff": 1,
-            "groups": [],
-            "user_permissions": [],
-            "password": "sha1$9efbf$da0bd72857bce1d486bd263b36482fa2fc82336d",
-            "email": "example@example.com",
-            "date_joined": "2009-10-30 03:17:26"
-        }
-    }
-]

test_proj/settings.py

 # settings for django-admin-tools test project.
 import os
 PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
-
+MEDIA_ROOT = os.path.join(PROJECT_PATH, 'static')
+MEDIA_URL = '/static/'
 DATABASE_ENGINE = 'sqlite3'
 DATABASE_NAME = ':memory:'
 SITE_ID = 1

test_proj/static/admin_tools

+../../admin_tools/media/admin_tools

test_proj/test_app/fixtures/initial_data.json

+[
+    {
+        "pk": 1,
+        "model": "auth.user",
+        "fields": {
+            "username": "user",
+            "first_name": "",
+            "last_name": "",
+            "is_active": 1,
+            "is_superuser": 1,
+            "is_staff": 1,
+            "groups": [],
+            "user_permissions": [],
+            "password": "sha1$9efbf$da0bd72857bce1d486bd263b36482fa2fc82336d",
+            "email": "example@example.com",
+            "date_joined": "2009-10-30 03:17:26"
+        }
+    }
+]

test_proj/test_app/tests.py

 from django.test import TestCase
 
 class AdminBasicTest(TestCase):
-    fixtures = ['users.json']
     def test_admin_loads(self):
-        c = self.client
-        self.assertTrue(c.login(username='user', password='123'))
-        res = c.get('/admin/')
+        self.assertTrue(self.client.login(username='user', password='123'))
+        res = self.client.get('/admin/')
         self.assertEqual(res.status_code, 200)

test_proj/urls.py

 from django.conf.urls.defaults import *
+from django.conf import settings
+from django.contrib import admin
 
-from django.contrib import admin
 admin.autodiscover()
 
 urlpatterns = patterns('',
     (r'^admin/', include(admin.site.urls)),
     url(r'^admin_tools/', include('admin_tools.urls')),
+    (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
 )
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.