Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
    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))
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 def test_device_obj_str(self):
     device = Device()
     self.assertEqual(str(device), 'Device :: width=0 height=0 pixel-ratio=1.0')