Esempio n. 1
0
class B2APITest(TestCase):
    def setUp(self):
        # Todo mock this and pass fake data here (?)
        remove_recursive_silently(DB_PATH)
        config = get_config()
        self.fileAPI = FileAPI(
            account_id=config["accountId"],
            application_key=config["applicationKey"],
            bucket_id=config["bucketId"],
            db_file=DB_PATH,
        )

    def _upload_file(self):
        # Tested code expects a file object, but binary stream shoudl have sam eAPI.
        binary_stream = io.BytesIO(TEST_BINARY_DATA)
        self.fileAPI.upload(binary_stream, TEST_INODE)

    def test_upload_file(self):
        self._upload_file()

    def test_delete_file(self):
        self._upload_file()
        self.fileAPI.delete(TEST_INODE)

    def test_download_file(self):
        self._upload_file()
        file = self.fileAPI.download(TEST_INODE)
        assert file.read() == TEST_BINARY_DATA
Esempio n. 2
0
 def setUp(self):
     # Todo mock this and pass fake data here (?)
     remove_recursive_silently(DB_PATH)
     config = get_config()
     self.fileAPI = FileAPI(
         account_id=config["accountId"],
         application_key=config["applicationKey"],
         bucket_id=config["bucketId"],
         db_file=DB_PATH,
     )
Esempio n. 3
0
 def setUp(self):
     # Todo mock this and pass fake data here (?)
     remove_recursive_silently(DB_PATH)
     file_info_store = FileInfoStore(DB_PATH)
     config = get_config()
     self.fileAPI = FileAPI(
         file_info_store=file_info_store,
         account_id=config["accountId"],
         application_key=config["applicationKey"],
         bucket_id=config["bucketId"],
     )
Esempio n. 4
0
 def setUp(self):
     remove_recursive_silently(DB_PATH)
     config = get_config()
     self.api = FileAPI(
         account_id=config["accountId"],
         application_key=config["applicationKey"],
         bucket_id=config["bucketId"],
         db_file=DB_PATH,
     )
     self.context = IntegrationTestingContext(api=self.api)
     self.filesystem = Filesystem(self.context.cache)