|
@@ 268-312 (lines=45) @@
|
| 265 |
|
assert downloaded_file_content == file_content |
| 266 |
|
assert downloaded_file_content != new_file_content |
| 267 |
|
|
| 268 |
|
def test_move_path(self): |
| 269 |
|
# create a file to move |
| 270 |
|
file_name = "test_move_file 🇳🇴 😗 🇫🇴 🇦🇽" |
| 271 |
|
file_content = "test move file content 🇳🇴 😗 🇫🇴 🇦🇽" |
| 272 |
|
self.create_and_upload_file(file_name, file_content) |
| 273 |
|
|
| 274 |
|
# move file |
| 275 |
|
destination_path = "new_test_move_file_location 🇳🇴 😗 🇫🇴 🇦🇽" |
| 276 |
|
res = self.nxc_local.move_path(self.user_username, file_name, destination_path) |
| 277 |
|
assert res.is_ok |
| 278 |
|
assert res.raw.status_code == self.CREATED_CODE |
| 279 |
|
# check only new file exist |
| 280 |
|
original_file_props = self.nxc_local.list_folders(self.user_username, file_name) |
| 281 |
|
moved_file = self.nxc_local.list_folders(self.user_username, destination_path) |
| 282 |
|
assert original_file_props.data is None |
| 283 |
|
assert len(moved_file.data) == 1 |
| 284 |
|
|
| 285 |
|
# copy file to already exist location |
| 286 |
|
|
| 287 |
|
# create a file to move |
| 288 |
|
file_name = "test_move_file 🇳🇴 😗 🇫🇴 🇦🇽" |
| 289 |
|
file_content = "test move file content 🇳🇴 😗 🇫🇴 🇦🇽" |
| 290 |
|
self.create_and_upload_file(file_name, file_content) |
| 291 |
|
|
| 292 |
|
# create new file for conflict |
| 293 |
|
new_file_name = 'test_move_file_ 🇳🇴 😗 🇫🇴 🇦🇽' |
| 294 |
|
new_file_content = 'test_move_file_ 🇳🇴 😗 🇫🇴 🇦🇽' |
| 295 |
|
self.create_and_upload_file(new_file_name, new_file_content) |
| 296 |
|
|
| 297 |
|
# move file to the new file location |
| 298 |
|
res = self.nxc_local.move_path(self.user_username, file_name, new_file_name) |
| 299 |
|
assert not res.is_ok |
| 300 |
|
assert res.raw.status_code == self.PRECONDITION_FAILED_CODE |
| 301 |
|
# move with overriding |
| 302 |
|
res = self.nxc_local.move_path(self.user_username, file_name, new_file_name, overwrite=True) |
| 303 |
|
assert res.is_ok |
| 304 |
|
assert res.raw.status_code == self.NO_CONTENT_CODE |
| 305 |
|
|
| 306 |
|
# download just copied file and check content |
| 307 |
|
os.remove(os.path.join(os.getcwd(), new_file_name)) # remove file locally to download it |
| 308 |
|
self.nxc_local.download_file(self.user_username, new_file_name) |
| 309 |
|
with open(new_file_name, 'r') as f: |
| 310 |
|
downloaded_file_content = f.read() |
| 311 |
|
assert downloaded_file_content == file_content |
| 312 |
|
assert downloaded_file_content != new_file_content |
| 313 |
|
|
| 314 |
|
def test_set_list_favorites(self): |
| 315 |
|
# create new file to make favorite |
|
@@ 230-266 (lines=37) @@
|
| 227 |
|
assert res.raw.status_code == self.NOT_FOUND_CODE |
| 228 |
|
assert not res.is_ok |
| 229 |
|
|
| 230 |
|
def test_copy_path(self): |
| 231 |
|
# create a file to copy |
| 232 |
|
file_name = "test_file" |
| 233 |
|
file_content = "test file content" |
| 234 |
|
self.create_and_upload_file(file_name, file_content) |
| 235 |
|
|
| 236 |
|
# copy file |
| 237 |
|
destination_path = "new_test_file_location" |
| 238 |
|
res = self.nxc_local.copy_path(self.user_username, file_name, destination_path) |
| 239 |
|
assert res.raw.status_code == self.CREATED_CODE |
| 240 |
|
assert res.is_ok |
| 241 |
|
# check both file exist |
| 242 |
|
original_file_props = self.nxc_local.list_folders(self.user_username, file_name) |
| 243 |
|
copy_props = self.nxc_local.list_folders(self.user_username, destination_path) |
| 244 |
|
assert len(original_file_props.data) == 1 |
| 245 |
|
assert len(copy_props.data) == 1 |
| 246 |
|
|
| 247 |
|
# copy file to already exist location |
| 248 |
|
# create new file |
| 249 |
|
new_file_name = 'test_file_2' |
| 250 |
|
new_file_content = 'test_file_3' |
| 251 |
|
self.create_and_upload_file(new_file_name, new_file_content) |
| 252 |
|
res = self.nxc_local.copy_path(self.user_username, file_name, new_file_name) |
| 253 |
|
assert not res.is_ok |
| 254 |
|
assert res.raw.status_code == self.PRECONDITION_FAILED_CODE |
| 255 |
|
# copy with overriding |
| 256 |
|
res = self.nxc_local.copy_path(self.user_username, file_name, new_file_name, overwrite=True) |
| 257 |
|
assert res.is_ok |
| 258 |
|
assert res.raw.status_code == self.NO_CONTENT_CODE |
| 259 |
|
|
| 260 |
|
# download just copied file and check content |
| 261 |
|
os.remove(os.path.join(os.getcwd(), new_file_name)) # remove file locally to download it |
| 262 |
|
self.nxc_local.download_file(self.user_username, new_file_name) |
| 263 |
|
with open(new_file_name, 'r') as f: |
| 264 |
|
downloaded_file_content = f.read() |
| 265 |
|
assert downloaded_file_content == file_content |
| 266 |
|
assert downloaded_file_content != new_file_content |
| 267 |
|
|
| 268 |
|
def test_move_path(self): |
| 269 |
|
# create a file to move |