Przeglądaj źródła

Added helper command to creation migrations

master
David Winterbottom 13 lat temu
rodzic
commit
42bfbd6dfc
4 zmienionych plików z 102 dodań i 75 usunięć
  1. 22
    0
      create_migration.py
  2. 1
    75
      run_tests.py
  3. 1
    0
      testing-reqs.txt
  4. 78
    0
      tests/config.py

+ 22
- 0
create_migration.py Wyświetl plik

@@ -0,0 +1,22 @@
1
+#!/usr/bin/env python
2
+import sys
3
+import os
4
+from optparse import OptionParser
5
+
6
+import tests.config
7
+
8
+
9
+def create_migration(app_label, **kwargs):
10
+    from south.management.commands.schemamigration import Command
11
+    com = Command()
12
+    com.handle(app=app_label, **kwargs)
13
+
14
+
15
+if __name__ == '__main__':
16
+    parser = OptionParser()
17
+    parser.add_option('-i', '--initial', dest='initial',
18
+                      action='store_true', default=False)
19
+    parser.add_option('-a', '--auto', dest='auto',
20
+                      action='store_true', default=False)
21
+    (options, args) = parser.parse_args()
22
+    create_migration(args[0], **options)

+ 1
- 75
run_tests.py Wyświetl plik

@@ -3,81 +3,7 @@ import sys
3 3
 import os
4 4
 from optparse import OptionParser
5 5
 
6
-from django.conf import settings, global_settings
7
-
8
-if not settings.configured:
9
-    from oscar.defaults import *
10
-    oscar_settings = dict([(k, v) for k, v in locals().items() if k.startswith('OSCAR_')])
11
-
12
-    # Helper function to extract absolute path
13
-    location = lambda x: os.path.join(os.path.dirname(os.path.realpath(__file__)), x)
14
-
15
-    settings.configure(
16
-            DATABASES={
17
-                'default': {
18
-                    'ENGINE': 'django.db.backends.sqlite3',
19
-                    }
20
-                },
21
-            INSTALLED_APPS=[
22
-                'django.contrib.auth',
23
-                'django.contrib.admin',
24
-                'django.contrib.contenttypes',
25
-                'django.contrib.sessions',
26
-                'django.contrib.sites',
27
-                # Oscar apps
28
-                'oscar',
29
-                'oscar.apps.analytics',
30
-                'oscar.apps.discount',
31
-                'oscar.apps.order',
32
-                'oscar.apps.checkout',
33
-                'oscar.apps.shipping',
34
-                'oscar.apps.catalogue',
35
-                'oscar.apps.catalogue.reviews',
36
-                'oscar.apps.basket',
37
-                'oscar.apps.payment',
38
-                'oscar.apps.offer',
39
-                'oscar.apps.address',
40
-                'oscar.apps.partner',
41
-                'oscar.apps.customer',
42
-                'oscar.apps.promotions',
43
-                'oscar.apps.search',
44
-                'oscar.apps.voucher',
45
-                'oscar.apps.dashboard',
46
-                'oscar.apps.dashboard.reports',
47
-                'oscar.apps.dashboard.users',
48
-                'oscar.apps.dashboard.orders'
49
-                ],
50
-            TEMPLATE_CONTEXT_PROCESSORS=(
51
-                "django.contrib.auth.context_processors.auth",
52
-                "django.core.context_processors.request",
53
-                "django.core.context_processors.debug",
54
-                "django.core.context_processors.i18n",
55
-                "django.core.context_processors.media",
56
-                "django.core.context_processors.static",
57
-                "django.contrib.messages.context_processors.messages",
58
-                'oscar.apps.search.context_processors.search_form',
59
-                'oscar.apps.promotions.context_processors.promotions',
60
-                'oscar.apps.checkout.context_processors.checkout',
61
-                ),
62
-            TEMPLATE_DIRS=(
63
-                location('tests/templates'),
64
-                ),
65
-            MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES + (
66
-                'oscar.apps.basket.middleware.BasketMiddleware',
67
-                ),
68
-            AUTHENTICATION_BACKENDS=(
69
-                'oscar.apps.customer.auth_backends.Emailbackend',
70
-                'django.contrib.auth.backends.ModelBackend',
71
-                ),
72
-            ROOT_URLCONF='tests.urls',
73
-            LOGIN_REDIRECT_URL='/accounts/',
74
-            DEBUG=False,
75
-            SITE_ID=1,
76
-            HAYSTACK_SEARCH_ENGINE='dummy',
77
-            HAYSTACK_SITECONF = 'oscar.search_sites',
78
-            APPEND_SLASH=True,
79
-            **oscar_settings
80
-        )
6
+import tests.config
81 7
 
82 8
 from django.test.simple import DjangoTestSuiteRunner
83 9
 

+ 1
- 0
testing-reqs.txt Wyświetl plik

@@ -11,3 +11,4 @@ ipdb==0.2
11 11
 ipython==0.10.1
12 12
 mock==0.7.0
13 13
 twill==0.9
14
+South==0.7.3

+ 78
- 0
tests/config.py Wyświetl plik

@@ -0,0 +1,78 @@
1
+import os
2
+
3
+from django.conf import settings, global_settings
4
+
5
+
6
+if not settings.configured:
7
+    from oscar.defaults import *
8
+    oscar_settings = dict([(k, v) for k, v in locals().items() if k.startswith('OSCAR_')])
9
+
10
+    # Helper function to extract absolute path
11
+    location = lambda x: os.path.join(os.path.dirname(os.path.realpath(__file__)), x)
12
+
13
+    settings.configure(
14
+            DATABASES={
15
+                'default': {
16
+                    'ENGINE': 'django.db.backends.sqlite3',
17
+                    }
18
+                },
19
+            INSTALLED_APPS=[
20
+                'django.contrib.auth',
21
+                'django.contrib.admin',
22
+                'django.contrib.contenttypes',
23
+                'django.contrib.sessions',
24
+                'django.contrib.sites',
25
+                # Oscar apps
26
+                'oscar',
27
+                'oscar.apps.analytics',
28
+                'oscar.apps.discount',
29
+                'oscar.apps.order',
30
+                'oscar.apps.checkout',
31
+                'oscar.apps.shipping',
32
+                'oscar.apps.catalogue',
33
+                'oscar.apps.catalogue.reviews',
34
+                'oscar.apps.basket',
35
+                'oscar.apps.payment',
36
+                'oscar.apps.offer',
37
+                'oscar.apps.address',
38
+                'oscar.apps.partner',
39
+                'oscar.apps.customer',
40
+                'oscar.apps.promotions',
41
+                'oscar.apps.search',
42
+                'oscar.apps.voucher',
43
+                'oscar.apps.dashboard',
44
+                'oscar.apps.dashboard.reports',
45
+                'oscar.apps.dashboard.users',
46
+                'oscar.apps.dashboard.orders'
47
+                ],
48
+            TEMPLATE_CONTEXT_PROCESSORS=(
49
+                "django.contrib.auth.context_processors.auth",
50
+                "django.core.context_processors.request",
51
+                "django.core.context_processors.debug",
52
+                "django.core.context_processors.i18n",
53
+                "django.core.context_processors.media",
54
+                "django.core.context_processors.static",
55
+                "django.contrib.messages.context_processors.messages",
56
+                'oscar.apps.search.context_processors.search_form',
57
+                'oscar.apps.promotions.context_processors.promotions',
58
+                'oscar.apps.checkout.context_processors.checkout',
59
+                ),
60
+            TEMPLATE_DIRS=(
61
+                location('templates'),
62
+                ),
63
+            MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES + (
64
+                'oscar.apps.basket.middleware.BasketMiddleware',
65
+                ),
66
+            AUTHENTICATION_BACKENDS=(
67
+                'oscar.apps.customer.auth_backends.Emailbackend',
68
+                'django.contrib.auth.backends.ModelBackend',
69
+                ),
70
+            ROOT_URLCONF='tests.urls',
71
+            LOGIN_REDIRECT_URL='/accounts/',
72
+            DEBUG=False,
73
+            SITE_ID=1,
74
+            HAYSTACK_SEARCH_ENGINE='dummy',
75
+            HAYSTACK_SITECONF = 'oscar.search_sites',
76
+            APPEND_SLASH=True,
77
+            **oscar_settings
78
+        )

Ładowanie…
Anuluj
Zapisz