def test_manage_account_delete(self): account = Account() account.username = "******" account.endpoint__dropbox_enabled = True new_token = PushToken() new_token.account = "michael" new_token.token = "token1" new_token.admin = True storage = Storage() storage.id = "id1" storage.account = "michael" storage.path = "/" storage.endpoint__amazon_s3_access_key_id = "endpoint__amazon_s3_access_key_id" storage.endpoint__amazon_s3_access_secret_key = "endpoint__amazon_s3_access_secret_key" storage.endpoint__dropbox_access_token = "endpoint__dropbox_access_token" storage.endpoint__dropbox_user_id = "endpoint__dropbox_user_id" storage.store_type = "dropbox" self.persist([account, new_token, storage]) self.app.delete( "/manage/account/storage?token=token1", data=json.dumps({"id": "id1"}) ) rv = self.app.get( "/manage/account/storage?token=token1", ) assert len(json.loads(rv.data)["storage"]) == 0
def test_manage_account_storage_save(self): account = Account() account.username = "******" account.endpoint__dropbox_enabled = True new_token = PushToken() new_token.account = "michael" new_token.token = "token1" new_token.admin = True storage = Storage() storage.id = "id1" storage.account = "michael" storage.path = "" storage.endpoint__amazon_s3_access_key_id = "" storage.endpoint__amazon_s3_access_secret_key = "" storage.endpoint__dropbox_access_token = "" storage.endpoint__dropbox_user_id = "" storage.store_type = "" self.persist([account, new_token, storage]) rv = self.app.post( "/manage/account/storage?token=token1", data=json.dumps({ "id": "id1", "path": "/path", "store_type": "dropbox" }) ) rv = self.app.get( "/manage/account/storage?token=token1", ) assert json.loads(rv.data) == { "storage": [ { "account": "michael", "endpoint__amazon_s3_access_key_id": "", "endpoint__amazon_s3_access_secret_key": "", "endpoint__dropbox_access_token": "", "endpoint__dropbox_user_id": "", "id": "id1", "path": "/path", "store_type": "dropbox" } ] }
def test__upload_file__dropbox__temp_user(self, __upload_dropbox): account = Account() account.username = "******" account.endpoint__dropbox_enabled = True credentials = TempCredentials() credentials.account = "michael" credentials.username = "******" credentials.permissions_mode = "w" credentials.permissions_path = "/" new_token = PushToken() new_token.account = "michael" new_token.token = "token1" new_token.admin = False new_token.authenticated_user = "******" storage = Storage() storage.id = "id1" storage.account = "michael" storage.path = "/" storage.endpoint__amazon_s3_access_key_id = "" storage.endpoint__amazon_s3_access_secret_key = "" storage.endpoint__dropbox_access_token = "" storage.endpoint__dropbox_user_id = "" storage.store_type = "dropbox" storage.permissions = "rw" self.persist([account, new_token, storage, credentials]) resp = self.app.post('/push/upload/token1', data={ 'file': (StringIO('my file contents'), 'hello world.txt'), 'path': "/hello world.txt" }) assert resp.status_code == 200 assert len(self.session.query(File).all()) == 1 assert __upload_dropbox.called == 1 __upload_dropbox.assert_called_with(mock.ANY, mock.ANY, '/hello world.txt')
def test__upload_file__s3(self, __upload_s3): account = Account() account.username = "******" account.endpoint__amazon_s3_enabled = True new_token = PushToken() new_token.account = "michael" new_token.token = "token1" new_token.admin = True storage = Storage() storage.id = "id1" storage.account = "michael" storage.path = "/" storage.endpoint__amazon_s3_access_key_id = "" storage.endpoint__amazon_s3_access_secret_key = "" storage.endpoint__dropbox_access_token = "" storage.endpoint__dropbox_user_id = "" storage.store_type = "s3" storage.permissions = "rw" self.persist([account, new_token, storage]) resp = self.app.post('/push/upload/token1', data={ 'file': (StringIO('my file contents'), 'hello world.txt'), 'path': '/dudes/path/hello world.txt' }) assert resp.status_code == 200 assert len(self.session.query(File).all()) == 1 assert __upload_s3.called == 1 __upload_s3.assert_called_with(mock.ANY, mock.ANY, '/dudes/path/hello world.txt')