Skip to content

Commit

Permalink
added new macros page
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinkler committed Mar 24, 2016
1 parent dcf694b commit af4ce24
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ month - (0?([1-9])|10|11|12)
day - ((0|1|2)?([1-9])|[1-3]0|31)
id - \d+
pk - \d+
page - \d+
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}
```

Expand Down
1 change: 1 addition & 0 deletions macrosurl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
_macros_library = {
'id': r'\d+',
'pk': r'\d+',
'page': r'\d+',
'slug': r'[\w-]+',
'year': r'\d{4}',
'month': r'(0?([1-9])|10|11|12)',
Expand Down
8 changes: 8 additions & 0 deletions tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ def test_pk(self):
'^product/(?P<pk>\d+)/(?P<product_pk>\d+)$')
self.assertEqual(MacroUrlPattern('product/:pk/:product_pk/:news_pk').compiled,
'^product/(?P<pk>\d+)/(?P<product_pk>\d+)/(?P<news_pk>\d+)$')

def test_page(self):
self.assertEqual(MacroUrlPattern('page/:page').compiled, '^page/(?P<page>\d+)$')
self.assertEqual(MacroUrlPattern('product/:product_page').compiled, '^product/(?P<product_page>\d+)$')
self.assertEqual(MacroUrlPattern('product/:page/:product_page').compiled,
'^product/(?P<page>\d+)/(?P<product_page>\d+)$')
self.assertEqual(MacroUrlPattern('product/:page/:product_page/:news_page').compiled,
'^product/(?P<page>\d+)/(?P<product_page>\d+)/(?P<news_page>\d+)$')

def test_slug(self):
self.assertEqual(MacroUrlPattern('page/:slug').compiled, '^page/(?P<slug>[\w-]+)$')
Expand Down

0 comments on commit af4ce24

Please sign in to comment.