Exemplo n.º 1
0
    def test_file_image_text_fields(self):
        class ATMultipleFields(atapi.BaseContent):
            schema = atapi.Schema((
                atapi.StringField('foo'),
                atapi.FileField('file1'),
                atapi.ImageField('image1'),
                atapi.ImageField('image2',
                                 sizes={
                                     'mini': (50, 50),
                                     'normal': (100, 100)
                                 }),
                atapi.TextField('text'),
            ))

        root = FauxContent('')
        context = ATMultipleFields('foo').__of__(root)
        purger = ObjectFieldPurgePaths(context)

        self.assertEqual(
            [
                '/foo/download',
                '/foo/at_download',
                '/foo/at_download/file1',
                '/foo/file1',
                '/foo/at_download/image1',
                '/foo/image1',
                '/foo/image1_thumb',
                '/foo/at_download/image2',
                '/foo/image2',
                '/foo/image2_mini',
                '/foo/image2_normal',
            ],
            list(purger.getRelativePaths()),
        )
        self.assertEqual([], list(purger.getAbsolutePaths()))
Exemplo n.º 2
0
    def test_file_image_fields(self):
        from plone.app.blob.field import BlobField

        class ATMultipleFields(atapi.BaseContent):
            schema = atapi.Schema((
                atapi.StringField('foo'),
                atapi.FileField('file1'),
                atapi.ImageField('image1'),
                atapi.ImageField('image2',
                                 sizes={
                                     'mini': (50, 50),
                                     'normal': (100, 100)
                                 }),
                BlobField('blob1'),
            ))

        context = ATMultipleFields('foo')
        purger = ObjectFieldPurgePaths(context)

        self.assertEqual([
            'foo/download', 'foo/at_download', 'foo/at_download/file1',
            'foo/file1', 'foo/at_download/image1', 'foo/image1',
            'foo/image1_thumb', 'foo/at_download/image2', 'foo/image2',
            'foo/image2_mini', 'foo/image2_normal', 'foo/at_download/blob1',
            'foo/blob1'
        ], list(purger.getRelativePaths()))
        self.assertEqual([], list(purger.getAbsolutePaths()))
Exemplo n.º 3
0
    def test_file_image_text_fields(self):

        class ATMultipleFields(atapi.BaseContent):
            schema = atapi.Schema((
                atapi.StringField('foo'),
                atapi.FileField('file1'),
                atapi.ImageField('image1'),
                atapi.ImageField('image2', sizes={
                                 'mini': (50, 50), 'normal': (100, 100)}),
                atapi.TextField('text'),
            ))

        root = FauxContent('')
        context = ATMultipleFields('foo').__of__(root)
        purger = ObjectFieldPurgePaths(context)

        self.assertEqual(
            [
                '/foo/download',
                '/foo/at_download',
                '/foo/at_download/file1',
                '/foo/file1',
                '/foo/at_download/image1',
                '/foo/image1',
                '/foo/image1_thumb',
                '/foo/at_download/image2',
                '/foo/image2',
                '/foo/image2_mini',
                '/foo/image2_normal'
            ],
            list(purger.getRelativePaths())
        )
        self.assertEqual([], list(purger.getAbsolutePaths()))
Exemplo n.º 4
0
    def test_no_file_image_fields(self):
        class ATNoFields(atapi.BaseContent):
            schema = atapi.Schema((atapi.StringField('foo'), ))

        context = ATNoFields('foo')
        purger = ObjectFieldPurgePaths(context)

        self.assertEqual([], list(purger.getRelativePaths()))
        self.assertEqual([], list(purger.getAbsolutePaths()))
Exemplo n.º 5
0
    def test_no_file_image_fields(self):

        class ATNoFields(atapi.BaseContent):
            schema = atapi.Schema((atapi.StringField('foo'),))

        context = ATNoFields('foo')
        purger = ObjectFieldPurgePaths(context)

        self.assertEqual([], list(purger.getRelativePaths()))
        self.assertEqual([], list(purger.getAbsolutePaths()))
Exemplo n.º 6
0
    def test_file_image_fields(self):
        from plone.app.blob.field import BlobField

        class ATMultipleFields(atapi.BaseContent):
            schema = atapi.Schema((
                    atapi.StringField('foo'),
                    atapi.FileField('file1'),
                    atapi.ImageField('image1'),
                    atapi.ImageField('image2', sizes={'mini': (50,50), 'normal' : (100,100)}),
                    BlobField('blob1'),
                ))
        
        context = ATMultipleFields('foo')
        purger = ObjectFieldPurgePaths(context)
        
        self.assertEquals(['foo/download', 'foo/at_download',
                           'foo/at_download/file1', 'foo/file1',
                           'foo/at_download/image1', 'foo/image1','foo/image1_thumb',
                           'foo/at_download/image2', 'foo/image2', 'foo/image2_mini', 'foo/image2_normal',
                           'foo/at_download/blob1', 'foo/blob1'],
                           list(purger.getRelativePaths()))
        self.assertEquals([], list(purger.getAbsolutePaths()))