Exemplo n.º 1
0
    def test_empty_image(self):
        """Test an image that doesn't store an image.
        """
        with Transaction():
            factory = self.root.manage_addProduct['Silva']
            with assertTriggersEvents('ObjectCreatedEvent'):
                factory.manage_addImage('image', 'Image')

        image = self.root.image
        self.assertTrue(verifyObject(interfaces.IImage, image))
        self.assertEqual(image.get_mime_type(), 'application/octet-stream')
        self.assertEqual(image.get_content_type(), 'application/octet-stream')
        self.assertEqual(image.get_filename(), 'image')
        self.assertEqual(image.get_file_size(), 0)
        self.assertEqual(image.get_file_system_path(), None)
        self.assertEqual(image.get_image(), None)
        self.assertNotEqual(image.get_modification_datetime(), None)
        self.assertNotEqual(image.get_creation_datetime(), None)

        payload = interfaces.IAssetPayload(image)
        self.assertTrue(verifyObject(interfaces.IAssetPayload, payload))
        self.assertEqual(payload.get_payload(), None)

        # Since the image is empty, a request to it will trigger a 404
        with self.layer.get_browser() as browser:
            self.assertEqual(browser.open('/root/image'), 404)
Exemplo n.º 2
0
 def test_asset_payload(self):
     """Test asset data adapter implementation.
     """
     content = self.create_test_file()
     payload = interfaces.IAssetPayload(content)
     self.assertTrue(verifyObject(interfaces.IAssetPayload, payload))
     self.assertHashEqual(self.file_data, payload.get_payload())
Exemplo n.º 3
0
 def test_asset_payload(self):
     """Test AssetPayload adapter.
     """
     payload = interfaces.IAssetPayload(self.root.test_image)
     self.assertTrue(verifyObject(interfaces.IAssetPayload, payload))
     self.assertEqual(payload.get_payload(), self.image_data)