|
18 | 18 | #
|
19 | 19 | # You should have received a copy of the GNU Affero General Public License
|
20 | 20 | # along with DjangoDav. If not, see <http://www.gnu.org/licenses/>.
|
| 21 | +import sys |
21 | 22 | from lxml.etree import ElementTree
|
22 | 23 | from django.http import HttpResponse, HttpRequest, Http404
|
23 | 24 | from djangodav.acls import FullAcl
|
@@ -325,34 +326,46 @@ def test_get_obj(self):
|
325 | 326 | self.assertEqual(resp['Etag'], "0" * 40)
|
326 | 327 | self.assertEqual(resp['Content-Type'], "text/plain")
|
327 | 328 | self.assertEqual(resp['Last-Modified'], "Wed, 24 Dec 2014 06:00:00 +0000")
|
328 |
| - self.assertEqual(resp.content, "C" * 42) |
| 329 | + if sys.version_info < (3, 0, 0): #py2 |
| 330 | + self.assertEqual(resp.content, "C" * 42) |
| 331 | + else: |
| 332 | + self.assertEqual(resp.content.decode('utf-8'), "C" * 42) |
329 | 333 |
|
330 |
| - @patch('djangodav.views.render_to_response', Mock(return_value=HttpResponse('listing'))) |
| 334 | + @patch('djangodav.views.render', Mock(return_value=HttpResponse('listing'))) |
331 | 335 | def test_head_object(self):
|
332 | 336 | path = '/object.txt'
|
333 | 337 | v = DavView(path=path, base_url='/base', _allowed_methods=Mock(return_value=['ALL']), acl_class=FullAcl)
|
334 | 338 | v.__dict__['resource'] = MockObject(path)
|
335 | 339 | resp = v.head(None, path)
|
336 | 340 | self.assertEqual("text/plain", resp['Content-Type'])
|
337 | 341 | self.assertEqual("Wed, 24 Dec 2014 06:00:00 +0000", resp['Last-Modified'])
|
338 |
| - self.assertEqual("", resp.content) |
| 342 | + if sys.version_info < (3, 0, 0): #py2 |
| 343 | + self.assertEqual("", resp.content) |
| 344 | + else: |
| 345 | + self.assertEqual("", resp.content.decode('utf-8')) |
339 | 346 | self.assertEqual("0", resp['Content-Length'])
|
340 | 347 |
|
341 |
| - @patch('djangodav.views.views.render_to_response', Mock(return_value=HttpResponse('listing'))) |
| 348 | + @patch('djangodav.views.views.render', Mock(return_value=HttpResponse('listing'))) |
342 | 349 | def test_get_collection(self):
|
343 | 350 | path = '/collection/'
|
344 | 351 | v = DavView(path=path, acl_class=FullAcl, base_url='/base', _allowed_methods=Mock(return_value=['ALL']))
|
345 | 352 | v.__dict__['resource'] = MockCollection(path)
|
346 | 353 | resp = v.get(None, path)
|
347 |
| - self.assertEqual("listing", resp.content) |
| 354 | + if sys.version_info < (3, 0, 0): #py2 |
| 355 | + self.assertEqual("listing", resp.content) |
| 356 | + else: |
| 357 | + self.assertEqual("listing", resp.content.decode('utf-8')) |
348 | 358 | self.assertEqual("Wed, 24 Dec 2014 06:00:00 +0000", resp['Last-Modified'])
|
349 | 359 |
|
350 | 360 | def test_head_collection(self):
|
351 | 361 | path = '/collection/'
|
352 | 362 | v = DavView(path=path, acl_class=FullAcl, base_url='/base', _allowed_methods=Mock(return_value=['ALL']))
|
353 | 363 | v.__dict__['resource'] = MockCollection(path)
|
354 | 364 | resp = v.head(None, path)
|
355 |
| - self.assertEqual("", resp.content) |
| 365 | + if sys.version_info < (3, 0, 0): #py2 |
| 366 | + self.assertEqual("", resp.content) |
| 367 | + else: |
| 368 | + self.assertEqual("", resp.content.decode('utf-8')) |
356 | 369 | self.assertEqual("Wed, 24 Dec 2014 06:00:00 +0000", resp['Last-Modified'])
|
357 | 370 | self.assertEqual("0", resp['Content-Length'])
|
358 | 371 |
|
|
0 commit comments