Skip to content

Commit

Permalink
updated tests for pixelratio
Browse files Browse the repository at this point in the history
  • Loading branch information
svleeuwen committed Mar 11, 2014
1 parent 57d6f78 commit a63e694
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion responsive/tests/test_context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_return_device_info(self):
def test_default_device_info(self):
"Return default info if info is not attached to the request."
result = device_info(self.request)
default = {'width': None, 'height': None, 'type': None}
default = {'width': None, 'height': None, 'type': None, 'pixelratio': None}
self.assertEqual(result['device_info'], default)

def test_device_type(self):
Expand Down
5 changes: 4 additions & 1 deletion responsive/tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def test_process_request_no_cookies(self):
self.assertEqual(device['width'], None)
self.assertEqual(device['height'], None)
self.assertEqual(device['type'], None)
self.assertEqual(device['pixelratio'], None)

def test_process_request_invalid_cookie(self):
"Process a request which has an invalid value in the cookie."
Expand All @@ -36,17 +37,19 @@ def test_process_request_invalid_cookie(self):
self.assertEqual(device['width'], None)
self.assertEqual(device['height'], None)
self.assertEqual(device['type'], None)
self.assertEqual(device['pixelratio'], None)

def test_process_request_valid_cookie(self):
"Read data from the cookie and make it available on the request."
# FIXME: Currently assumes default settings
self.request.COOKIES['resolution'] = '320:480'
self.request.COOKIES['resolution'] = '320:480:2'
self.middleware.process_request(request=self.request)
self.assertTrue(hasattr(self.request, 'device_info'))
device = self.request.device_info
self.assertEqual(device['width'], 320)
self.assertEqual(device['height'], 480)
self.assertEqual(device['type'], 'phone')
self.assertEqual(device['pixelratio'], 2)


class DeviceInfoScriptTestCase(unittest.TestCase):
Expand Down

0 comments on commit a63e694

Please sign in to comment.