|
3 | 3 | """ |
4 | 4 | from office365.sharepoint.client_context import ClientContext |
5 | 5 | from office365.sharepoint.files.move_operations import MoveOperations |
6 | | -from tests import create_unique_name, test_team_site_url, test_user_credentials |
| 6 | +from tests import test_team_site_url, test_user_credentials |
7 | 7 |
|
8 | 8 | ctx = ClientContext(test_team_site_url).with_credentials(test_user_credentials) |
9 | 9 |
|
10 | | -print("Creating temporary folders and uploading a file...") |
11 | | -path = "../../data/report #123.csv" |
12 | | -folder_from = ctx.web.default_document_library().root_folder.add( |
13 | | - create_unique_name("from") |
14 | | -) |
15 | | -folder_to = ctx.web.default_document_library().root_folder.add(create_unique_name("to")) |
16 | | -file = folder_from.files.upload(path).execute_query() |
17 | 10 |
|
18 | | -# copies the file with a new name into folder |
19 | | -print("Moving file to parent folder...") |
20 | | -file_to = file.move_to_using_path(folder_to, MoveOperations.overwrite).execute_query() |
21 | | -print( |
22 | | - "File has been copied from '{0}' into '{1}'".format( |
23 | | - file.server_relative_path, folder_to.serverRelativeUrl |
24 | | - ) |
| 11 | +file_from = ctx.web.get_file_by_server_relative_path( |
| 12 | + "Shared Documents/Financial Sample.xlsx" |
25 | 13 | ) |
| 14 | +# folder_to = ctx.web.get_folder_by_server_relative_url("Shared Documents") |
| 15 | +folder_to = "Shared Documents" |
26 | 16 |
|
27 | | -print("Cleaning up...") |
28 | | -folder_from.delete_object().execute_query() |
29 | | -folder_to.delete_object().execute_query() |
| 17 | +file_to = file_from.move_to_using_path( |
| 18 | + folder_to, MoveOperations.overwrite |
| 19 | +).execute_query() |
| 20 | +print("'{0}' moved into '{1}'".format(file_from, file_to)) |
0 commit comments