Пример #1
0
def test_transfer_ownership(request_mock) -> None:
    request_mock._iterable.append(
        ({"status": "200"}, read_datafile("transferownership.json", "rb")),
    )

    f = File("myfile", "0123456")
    assert f.transfer_ownership("*****@*****.**") == f
Пример #2
0
def test_copyTo(request_mock) -> None:
    request_mock._iterable.append(
        ({"status": "200"}, read_datafile("copyfile.json", "rb")),
    )

    f = File("myfile", "0123456")
    folder = Folder("myfolder", "abcdef")
    new_file = f.copyTo(folder, "New name")
    assert new_file.file_id == "MyNewId__"
    assert new_file.file_name == "Copy"
Пример #3
0
    def do(self) -> None:
        DriveService.configure(self.options.get("credentials"))
        user = self.options.get("user")
        role = self.options.get("role")
        fileId = self.options.get("fileid")

        file = File(fileId, fileId)

        if role == "owner":
            file.transfer_ownership(user)
        else:
            file.share(user, role, False)
Пример #4
0
    def do(self) -> None:
        DriveService.configure(self.options.get("credentials"))
        fileId = self.options.get("fileid")

        file = File(fileId, fileId)
        file.delete()
Пример #5
0
def test_init(request_mock) -> None:
    f = File("myfile", "0123456")
    assert f.client is not None
Пример #6
0
def test_delete(request_mock) -> None:
    request_mock._iterable.append(
        ({"status": "204"}, "{}"),
    )
    File("myfile", "0123456").delete()
Пример #7
0
def test_share(request_mock) -> None:
    request_mock._iterable.append(
        ({"status": "200"}, read_datafile("sharefile.json", "rb")),
    )
    f = File("myfile", "0123456")
    assert f.share("*****@*****.**", "writer", False) == f