Procházet zdrojové kódy

Reworked the way tests are run to not require the examples files.

master
David Winterbottom před 14 roky
rodič
revize
facf291a71
5 změnil soubory, kde provedl 194 přidání a 0 odebrání
  1. 93
    0
      run_tests.py
  2. 0
    0
      tests/__init__.py
  3. 20
    0
      tests/templates/base.html
  4. 68
    0
      tests/templates/layout.html
  5. 13
    0
      tests/urls.py

+ 93
- 0
run_tests.py Zobrazit soubor

@@ -0,0 +1,93 @@
1
+#!/usr/bin/env python
2
+import sys
3
+import os
4
+
5
+from django.conf import settings, global_settings
6
+
7
+if not settings.configured:
8
+    from oscar.defaults import *
9
+    oscar_settings = dict([(k, v) for k, v in locals().items() if k.startswith('OSCAR_')])
10
+
11
+    # Helper function to extract absolute path
12
+    location = lambda x: os.path.join(os.path.dirname(os.path.realpath(__file__)), x)
13
+
14
+    settings.configure(
15
+            DATABASES={
16
+                'default': {
17
+                    'ENGINE': 'django.db.backends.sqlite3',
18
+                    }
19
+                },
20
+            INSTALLED_APPS=[
21
+                'django.contrib.auth',
22
+                'django.contrib.admin',
23
+                'django.contrib.contenttypes',
24
+                'django.contrib.sessions',
25
+                'django.contrib.sites',
26
+                # Oscar apps
27
+                'oscar',
28
+                'oscar.apps.analytics',
29
+                'oscar.apps.discount',
30
+                'oscar.apps.order',
31
+                'oscar.apps.checkout',
32
+                'oscar.apps.shipping',
33
+                'oscar.apps.order_management',
34
+                'oscar.apps.catalogue',
35
+                'oscar.apps.catalogue.reviews',
36
+                'oscar.apps.basket',
37
+                'oscar.apps.payment',
38
+                'oscar.apps.payment.datacash',
39
+                'oscar.apps.offer',
40
+                'oscar.apps.address',
41
+                'oscar.apps.partner',
42
+                'oscar.apps.customer',
43
+                'oscar.apps.promotions',
44
+                'oscar.apps.reports',
45
+                'oscar.apps.search',
46
+                'oscar.apps.voucher',
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('tests/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
+            **oscar_settings
77
+        )
78
+
79
+from django.test.simple import DjangoTestSuiteRunner
80
+
81
+
82
+def run_tests():
83
+    # Modify path
84
+    parent = os.path.dirname(os.path.abspath(__file__))
85
+    sys.path.insert(0, parent)
86
+
87
+    # Run tests
88
+    test_runner = DjangoTestSuiteRunner(verbosity=2)
89
+    failures = test_runner.run_tests(['oscar'])
90
+    sys.exit(failures)
91
+
92
+if __name__ == '__main__':
93
+    run_tests()

+ 0
- 0
tests/__init__.py Zobrazit soubor


+ 20
- 0
tests/templates/base.html Zobrazit soubor

@@ -0,0 +1,20 @@
1
+<!DOCTYPE html>
2
+<html lang="{% block language %}en-gb{% endblock %}">
3
+    <head>
4
+        <title>{% block title %}Oscar :: Flexible ecommerce for Django{% endblock %}</title>
5
+        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
6
+        <meta name="created" content='{% now "jS M Y h:i" %}' />
7
+        <meta name="description" content="{% block description %}{% endblock %}" />
8
+        <meta name="keywords" content="{% block keywords %}{% endblock %}" />
9
+        <link rel="stylesheet" href="{{ STATIC_URL }}css/base/screen.css" />
10
+        {% block extra_head %}{% endblock %}
11
+    </head>
12
+    <body id="{% block body_id %}default{% endblock %}" class="{% block body_class %}default{% endblock %}">
13
+        {% block layout %}{% endblock %}
14
+        {% block tracking %}
15
+            {% if not debug and not request.user.is_staff %}
16
+                <!-- Tracking to go here. -->
17
+            {% endif %}
18
+        {% endblock %}
19
+    </body>
20
+</html>

+ 68
- 0
tests/templates/layout.html Zobrazit soubor

@@ -0,0 +1,68 @@
1
+{% extends "base.html" %}
2
+
3
+{% load currency_filters %}
4
+{% load promotions %}
5
+{% load category_tags %}
6
+
7
+{% block layout %}
8
+    <div id="container">
9
+        <div id="header">
10
+            <p><a href="{% url promotions:home %}">Oscar // Flexible e-commerce for Django</a></p>
11
+
12
+            <form method="get" action="{% url search:search %}">
13
+                {{ search_form.as_p }}
14
+                <input type="submit" value="Go!" />
15
+            </form>
16
+
17
+            {% if user.is_authenticated %}
18
+                <a href="{% url customer:summary %}">Profile</a>
19
+                <a href="{% url customer:logout %}">Logout</a>
20
+            {% else %}
21
+                <a href="{% url customer:login %}">Login</a>
22
+            {% endif %}
23
+
24
+            Basket total: {{ basket.total_incl_tax|currency }}
25
+            <a href="{% url basket:summary %}">View basket</a>
26
+
27
+			{% category_tree depth=2 as categories %}
28
+
29
+			{% if categories %}
30
+			<ul>
31
+			{% for category in categories %}
32
+			<li><a href="{{ category.0.get_absolute_url }}">{{ category.0.name }}</a>
33
+				{% if category.1 %}
34
+				<ul>
35
+				{% for subcategory in category.1 %}
36
+				<li><a href="{{ subcategory.0.get_absolute_url }}">{{ subcategory.0.name }}</a>
37
+				{% endfor %}
38
+				</ul>
39
+				{% endif %}
40
+			</li>
41
+			{% endfor %}
42
+			</ul>
43
+			{% endif %}
44
+
45
+            {% block header %}
46
+            {% endblock %}
47
+        </div>
48
+        <div id="content">
49
+
50
+            {% if messages %}
51
+            <ul class="messages">
52
+                {% for message in messages %}
53
+                <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
54
+                {% endfor %}
55
+            </ul>
56
+            {% endif %}
57
+
58
+            <div id="promotions">
59
+                {% for promotion in promotions_page %}
60
+                    {% render_promotion promotion %}
61
+                {% endfor %}
62
+            </div>
63
+
64
+            {% block content %}{% endblock %}
65
+        </div>
66
+        <div id="footer">{% block footer %}{% endblock %}</div>
67
+    </div>
68
+{% endblock %}

+ 13
- 0
tests/urls.py Zobrazit soubor

@@ -0,0 +1,13 @@
1
+from django.conf.urls.defaults import *
2
+from django.contrib import admin
3
+from django.contrib.staticfiles.urls import staticfiles_urlpatterns
4
+
5
+from oscar.app import shop
6
+
7
+admin.autodiscover()
8
+
9
+urlpatterns = patterns('',
10
+    (r'^admin/', include(admin.site.urls)),
11
+    (r'', include(shop.urls)),
12
+)
13
+urlpatterns += staticfiles_urlpatterns()

Načítá se…
Zrušit
Uložit