class GetFaviconsTest(TestCase): def setUp(self): self.storage = FakeStorage() def tearDown(self): HANDLED_FILES.clean() def test_get_favicons(self): generate(BASE_IMG, self.storage) html = get_favicons() urls = SRC_REG.findall(html) self.assertTrue(urls) for name in urls: self.assertTrue(self.storage.exists(name)) def test_get_favicons_with_prefix(self): prefix = 'foo/' generate(BASE_IMG, self.storage, prefix) html = get_favicons(prefix) urls = SRC_REG.findall(html) self.assertTrue(urls) for name in urls: self.assertTrue(self.storage.exists(name))
class GenerateTest(TestCase): def setUp(self): self.storage = FakeStorage() def tearDown(self): HANDLED_FILES.clean() def test_generate(self): generate(BASE_IMG, self.storage) for name, content in HANDLED_FILES['written_files'].items(): self.assertIn(name, EXPECTED_FILES) self.assertTrue(content.size) # Test ICO file ico = self.storage._open('favicon.ico') self.assertEqual(Image.open(ico).format, 'ICO') # Test PNG for size in PNG_SIZES: name = 'favicon-%d.png' % size self.assertTrue(self.storage.exists(name)) png = self.storage._open(name) img = Image.open(png) self.assertEqual(img.format, 'PNG') self.assertEqual(img.size, (size, size)) # Test Windows PNG for size, name in WINDOWS_PNG_SIZES: self.assertTrue(self.storage.exists(name)) png = self.storage._open(name) img = Image.open(png) self.assertEqual(img.format, 'PNG') if size[0] != size[1] or size[0] > 440: continue self.assertEqual(img.size, size) # Test ieconfig.xml ieconfig = self.storage._open('ieconfig.xml').read() for name in SRC_REG.findall(ieconfig): self.assertTrue(self.storage.exists(name)) def test_generate_with_prefix(self): prefix = 'foo/' expected_files = [prefix+fi for fi in EXPECTED_FILES] generate(BASE_IMG, self.storage, prefix) for name, content in HANDLED_FILES['written_files'].items(): self.assertIn(name, expected_files) self.assertTrue(content.size)
class GenerateTest(TestCase): def setUp(self): self.storage = FakeStorage() def tearDown(self): HANDLED_FILES.clean() def test_generate(self): generate(BASE_IMG, self.storage) for name, content in HANDLED_FILES['written_files'].items(): self.assertIn(name, EXPECTED_FILES) self.assertTrue(content.size) # Test ICO file ico = self.storage._open('favicon.ico') self.assertEqual(Image.open(ico).format, 'ICO') # Test PNG for size in PNG_SIZES: name = 'favicon-%d.png' % size self.assertTrue(self.storage.exists(name)) png = self.storage._open(name) img = Image.open(png) self.assertEqual(img.format, 'PNG') self.assertEqual(img.size, (size, size)) # Test Windows PNG for size, name in WINDOWS_PNG_SIZES: self.assertTrue(self.storage.exists(name)) png = self.storage._open(name) img = Image.open(png) self.assertEqual(img.format, 'PNG') if size[0] != size[1] or size[0] > 440: continue self.assertEqual(img.size, size) # Test ieconfig.xml ieconfig = self.storage._open('ieconfig.xml').read() for name in SRC_REG.findall(ieconfig): self.assertTrue(self.storage.exists(name)) def test_generate_with_prefix(self): prefix = 'foo/' expected_files = [prefix + fi for fi in EXPECTED_FILES] generate(BASE_IMG, self.storage, prefix) for name, content in HANDLED_FILES['written_files'].items(): self.assertIn(name, expected_files) self.assertTrue(content.size)
def setUp(self): self.storage = FakeStorage()
def setUp(self): self.command = Delete() self.storage = FakeStorage() generate(BASE_IMG, self.storage)
def setUp(self): self.storage = FakeStorage() generate(BASE_IMG, self.storage)
def test_favicon_url_with_prefix(self): url = favicon_url('foo.png', 'bar/') self.assertEqual(FakeStorage().url('bar/foo.png'), url)
def test_favicon_url(self): url = favicon_url('foo.png') self.assertEqual(FakeStorage().url('foo.png'), url)