def test_10_fileplugin_icon_uppercase(self): page = self.new_create_page(title="testpage") body = page.placeholders.get(slot="body") plugin = File(plugin_type="FilePlugin", placeholder=body, position=1, language=settings.LANGUAGE_CODE) plugin.file.save("UPPERCASE.JPG", SimpleUploadedFile("UPPERCASE.jpg", "content"), False) plugin.insert_at(None, position="last-child", commit=True) self.assertNotEquals(plugin.get_icon_url().find("jpg"), -1) response = self.client.get(plugin.get_icon_url(), follow=True) self.assertEqual(response.status_code, 200) plugin.file.storage.delete(plugin.file.name)
def test_fileplugin_icon_uppercase(self): page = create_page('testpage', 'nav_playground.html', 'en') body = page.placeholders.get(slot="body") plugin = File( plugin_type='FilePlugin', placeholder=body, position=1, language=settings.LANGUAGE_CODE, ) plugin.file.save("UPPERCASE.JPG", SimpleUploadedFile("UPPERCASE.jpg", "content"), False) plugin.insert_at(None, position='last-child', save=True) self.assertNotEquals(plugin.get_icon_url().find('jpg'), -1)
def test_10_fileplugin_icon_uppercase(self): page = self.create_page(title='testpage') body = page.placeholders.get(slot="body") plugin = File( plugin_type='FilePlugin', placeholder=body, position=1, language=settings.LANGUAGE_CODE, ) plugin.file.save("UPPERCASE.JPG", SimpleUploadedFile("UPPERCASE.jpg", "content"), False) plugin.insert_at(None, position='last-child', commit=True) self.assertEquals(plugin.get_icon_url().find('jpg') != -1, True)
def test_10_fileplugin_icon_uppercase(self): page = self.create_page(title='testpage') body = page.placeholders.get(slot="body") plugin = File( plugin_type='FilePlugin', placeholder=body, position=1, language=settings.LANGUAGE_CODE, ) plugin.file.save("UPPERCASE.JPG", SimpleUploadedFile("UPPERCASE.jpg", "content"), False) plugin.insert_at(None, position='last-child', commit=True) self.assertNotEquals(plugin.get_icon_url().find('jpg'), -1) response = self.client.get(plugin.get_icon_url(), follow=True) self.assertEqual(response.status_code, 200) # Nuke everything in the storage location directory (since removing just # our file would still leave a useless directory structure) # # By the way, plugin.file.storage.delete(plugin.file.name) does not work # since the delete method is a pass... See reversion.storage.delete() storage_location = plugin.file.storage.location # This is ".../media/" for root, dirs, files in os.walk(storage_location, topdown=False): # We need to walk() the directory tree since rmdir() does not allow # to remove non-empty directories... for name in files: # Start by killing all files we walked os.remove(os.path.join(root, name)) for name in dirs: # Now all directories we walked... os.rmdir(os.path.join(root, name))