|
| 1 | +import os |
1 | 2 | import sys
|
2 | 3 | import uuid
|
3 | 4 |
|
| 5 | +import django |
4 | 6 | from django.conf.urls import include
|
5 | 7 |
|
| 8 | +from macrosurl import MacroUrlPattern, url |
| 9 | + |
6 | 10 | if sys.version_info >= (2, 7):
|
7 | 11 | import unittest
|
8 | 12 | else:
|
9 | 13 | from django.utils import unittest
|
10 | 14 |
|
11 |
| -from macrosurl import MacroUrlPattern, url |
| 15 | +os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' |
| 16 | +django.setup() |
12 | 17 |
|
13 | 18 |
|
14 | 19 | class TestRegexCompilation(unittest.TestCase):
|
@@ -47,7 +52,7 @@ def test_pk(self):
|
47 | 52 | '^product/(?P<pk>\d+)/(?P<product_pk>\d+)$')
|
48 | 53 | self.assertEqual(MacroUrlPattern('product/:pk/:product_pk/:news_pk').compiled,
|
49 | 54 | '^product/(?P<pk>\d+)/(?P<product_pk>\d+)/(?P<news_pk>\d+)$')
|
50 |
| - |
| 55 | + |
51 | 56 | def test_page(self):
|
52 | 57 | self.assertEqual(MacroUrlPattern('page/:page').compiled, '^page/(?P<page>\d+)$')
|
53 | 58 | self.assertEqual(MacroUrlPattern('product/:product_page').compiled, '^product/(?P<product_page>\d+)$')
|
@@ -78,11 +83,14 @@ def test_date(self):
|
78 | 83 |
|
79 | 84 | def test_uid(self):
|
80 | 85 | self.assertEqual(MacroUrlPattern('invoice/:uuid').compiled,
|
81 |
| - '^invoice/(?P<uuid>[a-fA-F0-9]{8}-?[a-fA-F0-9]{4}-?[1345][a-fA-F0-9]{3}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{12})$') |
| 86 | + '^invoice/(?P<uuid>[a-fA-F0-9]{8}-?[a-fA-F0-9]{4}-?[1345][a-fA-F0-9]{3}-?[a-fA-F0-9]{4}-?[' |
| 87 | + 'a-fA-F0-9]{12})$') |
82 | 88 |
|
83 | 89 | def test_strongurl(self):
|
84 | 90 | self.assertEqual(MacroUrlPattern('orders/:date/:uuid/products/:slug/:variant_id').compiled,
|
85 |
| - '^orders/(?P<date>\\d{4}-(0?([1-9])|10|11|12)-((0|1|2)?([1-9])|[1-3]0|31))/(?P<uuid>[a-fA-F0-9]{8}-?[a-fA-F0-9]{4}-?[1345][a-fA-F0-9]{3}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{12})/products/(?P<slug>[\\w-]+)/(?P<variant_id>\\d+)$') |
| 91 | + '^orders/(?P<date>\\d{4}-(0?([1-9])|10|11|12)-((0|1|2)?([1-9])|[1-3]0|31))/(?P<uuid>[' |
| 92 | + 'a-fA-F0-9]{8}-?[a-fA-F0-9]{4}-?[1345][a-fA-F0-9]{3}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{' |
| 93 | + '12})/products/(?P<slug>[\\w-]+)/(?P<variant_id>\\d+)$') |
86 | 94 |
|
87 | 95 | # noinspection PyProtectedMember
|
88 | 96 | def test_includes_end(self):
|
|
0 commit comments