def test_get_media_queries_works(self): # min_width, min_height, max_height, pixel_ratio is not defined in above settings # get_media_queries() should set them to None device = Device() media_queries = device.get_media_queries() for attr in ('min_width', 'min_height', 'max_height', 'pixel_ratio'): self.assertEqual(media_queries['small'][attr], None)
def test_caching(self): device = Device(width=1366, height=768) # matched devices should be cached self.assertIsNotNone(cache.get(device.cache_key)) # clear the cache device.clear() self.assertIsNone(cache.get(device.cache_key))
def test_matched_media_queries(self): device = Device(width=1366, height=768, pixel_ratio=2) self.assertIn('large', device.matched) self.assertIn('retina', device.matched)
def test_get_media_queries_fails(self): # get_media_queries() should raise ImproperlyConfigured with above settings device = Device() self.assertRaises(ImproperlyConfigured, device.get_media_queries)
def test_device_default_values(self): device = Device() self.assertEqual(device.width, settings.RESPONSIVE_DEFAULT_WIDTH) self.assertEqual(device.height, settings.RESPONSIVE_DEFAULT_HEIGHT) self.assertEqual(device.pixel_ratio, settings.RESPONSIVE_DEFAULT_PIXEL_RATIO)
def test_device_obj_str(self): device = Device() self.assertEqual(str(device), 'Device :: width=0 height=0 pixel-ratio=1.0')