@@ -81,59 +81,64 @@ def test_includes_end(self):
8181
8282class TestRegexUrlResolving (unittest .TestCase ):
8383 def setUp (self ):
84+ self .view = 'tests.views.view'
85+ 8486 if not settings .configured :
8587 settings .configure (USE_I18N = False )
8688
8789 def test_id (self ):
88- self .assertIsNone (url ('product/:id' , 'view' ).resolve ('product/test' ))
89- self .assertIsNotNone (url ('product/:id' , 'view' ).resolve ('product/10' ))
90- self .assertEqual (url ('product/:id' , 'view' ).resolve ('product/10' ).kwargs ['id' ], '10' )
91- self .assertEqual (url ('product/:product_id' , 'view' ).resolve ('product/10' ).kwargs ['product_id' ], '10' )
90+ self .assertIsNone (url ('product/:id' , self .view ).resolve ('product/test' ))
91+ self .assertIsNotNone (url ('product/:id' , self .view ).resolve ('product/10' ))
92+ self .assertEqual (url ('product/:id' , self .view ).resolve ('product/10' ).kwargs ['id' ], '10' )
93+ self .assertEqual (url ('product/:product_id' , self .view ).resolve ('product/10' ).kwargs ['product_id' ],
94+ '10' )
9295
9396 def test_slug (self ):
94- self .assertIsNone (url ('product/:slug' , ' view' ).resolve ('product/test/ouch' ))
95- self .assertIsNotNone (url ('product/:slug' , ' view' ).resolve ('product/test' ))
96- self .assertIsNotNone (url ('product/:slug/:other_slug' , ' view' ).resolve ('product/test/other' ))
97+ self .assertIsNone (url ('product/:slug' , self . view ).resolve ('product/test/ouch' ))
98+ self .assertIsNotNone (url ('product/:slug' , self . view ).resolve ('product/test' ))
99+ self .assertIsNotNone (url ('product/:slug/:other_slug' , self . view ).resolve ('product/test/other' ))
97100
98101 def test_year (self ):
99- self .assertIsNone (url ('news/:year' , ' view' ).resolve ('news/last' ))
102+ self .assertIsNone (url ('news/:year' , self . view ).resolve ('news/last' ))
100103 for y in range (1970 , 2025 ):
101- self .assertIsNotNone (url ('news/:year' , ' view' ).resolve ('news/%s' % y ))
102- self .assertIsNone (url ('news/:year/last' , ' view' ).resolve ('news/2014/other' ))
103- self .assertIsNotNone (url ('news/:year/last' , ' view' ).resolve ('news/2014/last' ))
104+ self .assertIsNotNone (url ('news/:year' , self . view ).resolve ('news/%s' % y ))
105+ self .assertIsNone (url ('news/:year/last' , self . view ).resolve ('news/2014/other' ))
106+ self .assertIsNotNone (url ('news/:year/last' , self . view ).resolve ('news/2014/last' ))
104107
105108 def test_year_month (self ):
106- self .assertIsNone (url ('news/:year/:month' , ' view' ).resolve ('news/2014/last' ))
107- self .assertIsNone (url ('news/:year/:month' , ' view' ).resolve ('news/2014/2012' ))
109+ self .assertIsNone (url ('news/:year/:month' , self . view ).resolve ('news/2014/last' ))
110+ self .assertIsNone (url ('news/:year/:month' , self . view ).resolve ('news/2014/2012' ))
108111 for y in range (1970 , 2025 ):
109112 for m in range (1 , 12 ):
110- self .assertIsNotNone (url ('news/:year/:month' , ' view' ).resolve ('news/%s/%s' % (y , m )))
113+ self .assertIsNotNone (url ('news/:year/:month' , self . view ).resolve ('news/%s/%s' % (y , m )))
111114
112- self .assertIsNotNone (url ('news/:year/:month/last' , ' view' ).resolve ('news/2014/12/last' ))
115+ self .assertIsNotNone (url ('news/:year/:month/last' , self . view ).resolve ('news/2014/12/last' ))
113116
114117 def test_year_month_day (self ):
115- self .assertIsNone (url ('news/:year/:month/:day' , ' view' ).resolve ('news/2014/12/last' ))
116- self .assertIsNone (url ('news/:year/:month/:day' , ' view' ).resolve ('news/2014/2012/31' ))
118+ self .assertIsNone (url ('news/:year/:month/:day' , self . view ).resolve ('news/2014/12/last' ))
119+ self .assertIsNone (url ('news/:year/:month/:day' , self . view ).resolve ('news/2014/2012/31' ))
117120 for y in range (2000 , 2020 ):
118121 for m in range (1 , 12 ):
119122 for d in range (1 , 31 ):
120- self .assertIsNotNone (url ('news/:year/:month/:day' , ' view' ).resolve ('news/%s/%s/%s' % (y , m , d )))
123+ self .assertIsNotNone (url ('news/:year/:month/:day' , self . view ).resolve ('news/%s/%s/%s' % (y , m , d )))
121124
122125 def test_date (self ):
123- self .assertIsNone (url ('news/:date' , ' view' ).resolve ('news/2014/12/12' ))
126+ self .assertIsNone (url ('news/:date' , self . view ).resolve ('news/2014/12/12' ))
124127 for y in range (2000 , 2020 ):
125128 for m in range (1 , 12 ):
126129 for d in range (1 , 31 ):
127- self .assertIsNotNone (url ('news/:date' , ' view' ).resolve ('news/%s-%s-%s' % (y , m , d )))
130+ self .assertIsNotNone (url ('news/:date' , self . view ).resolve ('news/%s-%s-%s' % (y , m , d )))
128131
129132 def test_uuid (self ):
130133 self .assertIsNone (url ("invoice/:uuid" , 'view' ).resolve ('invoice/123123-123123-1231231-1231312-3-1312312-' ))
131134 for i in range (1 , 1000 ):
132- self .assertIsNotNone (url ("invoice/:uuid" , ' view' ).resolve ('invoice/%s' % uuid .uuid4 ()))
135+ self .assertIsNotNone (url ("invoice/:uuid" , self . view ).resolve ('invoice/%s' % uuid .uuid4 ()))
133136
134137 def test_no_match_for_invalid_uuid (self ):
135138 """
136139 UUID with invalid version. The allowed versions are 1, 2, 4 and 5
137140 xxxxxxxx-xxxx-Vxxx-xxx-xxxxxxxxxxxx
141+
142+ https://github.com/phpdude/django-macros-url/pull/2
138143 """
139- self .assertIsNone (url ("invoice/:uuid" , ' view' ).resolve ('invoice/3e41b04d-0978-9027-86c2-aa90c63ecb54' ))
144+ self .assertIsNone (url ("invoice/:uuid" , self . view ).resolve ('invoice/3e41b04d-0978-9027-86c2-aa90c63ecb54' ))
0 commit comments