def setup_method(self): self.app = App() self.app.bind('Application', application) self.app.bind('StorageConfig', storage) self.app.bind('UploadDiskDriver', UploadDiskDriver) self.app.bind('UploadManager', UploadManager(self.app)) self.app.bind('Upload', UploadManager(self.app)) self.app.bind('UploadS3Driver', UploadS3Driver)
def test_upload_file_for_s3(): container = App() container.bind('Application', application) container.bind('StorageConfig', storage) container.bind('UploadDiskDriver', UploadDiskDriver) container.bind('UploadManager', UploadManager(container)) container.bind('Upload', UploadManager(container)) container.bind('UploadS3Driver', UploadS3Driver) img = ImageTest() assert container.make('Upload').driver('s3').store(img) is None
def test_upload_file_with_location_from_driver(self): """ This test is responsible for checking if you upload a file correctly. """ assert UploadManager(self.app).driver('disk').store( ImageMock(), 'disk.uploading')
def test_upload_manage_accept_files_error(self): """ This test should return an error because it is an invalid extension. """ with pytest.raises(FileTypeException): UploadManager(self.app).driver('s3').accept('png').store( ImageMock())
def test_upload_manager_validates_file_ext(self): """ This test is responsible for checking if you upload a file correctly with a valid extension. """ assert UploadManager(self.app).driver('disk').accept( 'jpg', 'png').validate_extension('test.png')
def test_upload_manage_accept_files(self): """ This test is responsible for checking if you upload a file correctly with a valid extension. """ assert UploadManager(self.app).driver('disk').accept( 'jpg', 'png').store(ImageMock())
def test_upload_file(self): """ This test is responsible for checking if you upload a file correctly. """ self.assertTrue( UploadManager(self.app).driver('disk').store(ImageMock()))
def test_upload_manager_raises_driver_not_found_error(self): self.app = App() self.app.bind('Test', object) self.app.bind('StorageConfig', storage) with pytest.raises(DriverNotFound): assert self.app.bind('UploadManager', UploadManager().load_container(self.app))
def setup_method(self): self.app = App() self.app.bind('Test', object) self.app.bind('StorageConfig', storage) self.app.bind('UploadDiskDriver', UploadDiskDriver) self.app.bind('Application', application) self.app.bind('UploadManager', UploadManager().load_container(self.app))
def test_upload_manage_should_raise_exception_when_accept_all_extension_and_something_more( self): """ This test should raise an error when use something together with '*' when allowing all extensions ) """ with self.assertRaises(ValueError): UploadManager(self.app).driver('disk').accept('*', 'png').store( ImageMock())
def test_upload_file(): """ This test is responsible for checking if you upload a file correctly. """ container = App() container.bind('Application', application) container.bind('StorageConfig', storage) container.bind('UploadDiskDriver', UploadDiskDriver) container.bind('UploadManager', UploadManager(container)) container.bind('Upload', UploadManager(container)) container.bind('UploadS3Driver', UploadS3Driver) img = ImageTest() assert UploadManager(container).driver('disk').store(img)
def test_upload_manager_raises_driver_not_found_error(): container = App() container.bind('Test', object) container.bind('StorageConfig', storage) with pytest.raises(DriverNotFound): assert container.bind('UploadManager', UploadManager().load_container(container))
def test_upload_store_prepend(): container = App() container.bind('Application', application) container.bind('StorageConfig', storage) container.bind('UploadDiskDriver', UploadDiskDriver) container.bind('UploadManager', UploadManager(container)) assert container.make('UploadManager').driver('disk').store_prepend( ImageTest(), 'hey') == 'uploads/heytest.jpg'
def test_upload_manager_grabs_drivers(): container = App() container.bind('Test', object) container.bind('StorageConfig', storage) container.bind('UploadDiskDriver', UploadDiskDriver) container.bind('Application', application) container.bind('UploadManager', UploadManager().load_container(container)) assert isinstance( container.make('UploadManager').driver('disk'), UploadDiskDriver)
def test_upload_manage_accept_all_extensions(self): """ This test should upload a file correctly by allowing all type files ( .accept('*') ) """ image = ImageMock() image.filename = 'file.pdf' print(image.filename) self.assertTrue( UploadManager(self.app).driver('disk').accept('*').store(image))
def test_upload_manage_accept_files_error(): """ This test should return an error because it is an invalid extension. """ container = App() container.bind('Application', application) container.bind('StorageConfig', storage) container.bind('UploadDiskDriver', UploadDiskDriver) img = ImageTest() with pytest.raises(FileTypeException): UploadManager(container).driver('disk').accept('png').store(img)
def test_upload_manage_accept_files(): """ This test is responsible for checking if you upload a file correctly with a valid extension. """ container = App() container.bind('Application', application) container.bind('StorageConfig', storage) container.bind('UploadDiskDriver', UploadDiskDriver) img = ImageTest() assert UploadManager(container).driver('disk').accept('jpg', 'png').store(img)
def register(self): self.app.bind('StorageConfig', storage) self.app.bind('UploadDiskDriver', UploadDiskDriver) self.app.bind('UploadS3Driver', UploadS3Driver) self.app.bind('UploadManager', UploadManager(self.app))
def boot(self, UploadManager, StorageConfig): self.app.bind('Upload', UploadManager.driver(StorageConfig.DRIVER))
def boot(self, UploadManager, StorageConfig, ViewClass): self.app.bind('Upload', UploadManager.driver(StorageConfig.DRIVER)) ViewClass.share({ 'static': static, })