Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(12)  |  Call(11)  |  Derive(0)  |  Import(1)

src/a/r/archetypes.uploadreferencewidget-0.2.1/archetypes/uploadreferencewidget/tests/test_widget.py   archetypes.uploadreferencewidget(Download)
 
from archetypes.uploadreferencewidget.tests.utils import FakeRequest
from archetypes.uploadreferencewidget.tests.utils import FakeFileUpload
 
 
    def uploadContentToPath(self, obj, path, destination):
        field = obj.getField('relatedItems')
        fileupload = FakeFileUpload(filename='enfold.pdf', file=self.PDF)
        field.widget = UploadReferenceWidget(startup_directory=path)
        form = {
    def testValidateUploadWithoutSelectAFileInARequiredField(self):
        fileupload = FakeFileUpload(filename='', file=StringIO())
        self.field.widget = UploadReferenceWidget()
        self.field.required = True
        self.field.multiValued = False
 
        # Finally, upload a valid file. Again, no error:
        fileupload = FakeFileUpload(filename='foo.txt', file=StringIO('foo'))
        form = {
            'relatedItems': '',
    def testUploadImageCreateObjectAndReference(self):
        fileupload = FakeFileUpload(filename='enfold.gif', file=self.IMG)
        self.field.widget = UploadReferenceWidget(startup_directory='test')
        self.portal.invokeFactory('Folder', id='test')
        form = {