def setUp(self):
            self.app = App()
            self.app.bind('Container', self.app)

            # 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_manager_raises_driver_not_found_error(self):
        self.app = App()
        self.app.bind('Test', object)
        # self.app.bind('StorageConfig', storage)

        with self.assertRaises(DriverNotFound):
            self.assertIsNone(self.app.bind(
                'UploadManager',
                UploadManager(self.app).load_container(self.app)
            ))
    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_file_with_location_from_driver(self):
        """
        This test is responsible for checking if you upload a file correctly.
        """

        self.assertTrue(UploadManager(self.app).driver('disk').store(ImageMock(), location='disk.uploading'))
    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_manage_accept_files_error(self):
     """
     This test should return an error because it is an invalid extension.
     """
     with self.assertRaises(FileTypeException):
         UploadManager(self.app).driver('s3').accept('png').store(ImageMock())
 def test_upload_manage_accept_files(self):
     """
     This test is responsible for checking if you upload
     a file correctly with a valid extension.
     """
     self.assertTrue(UploadManager(self.app).driver('s3').accept('jpg', '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.
     """
     self.assertTrue(UploadManager(self.app).driver('disk').accept('jpg', 'png').validate_extension('test.png'))
 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())