|
@@ 210-254 (lines=45) @@
|
| 207 |
|
assert downloaded_file_content == file_content |
| 208 |
|
assert downloaded_file_content != new_file_content |
| 209 |
|
|
| 210 |
|
def test_move_path(self): |
| 211 |
|
# create a file to move |
| 212 |
|
file_name = "test_move_file 🇳🇴 😗 🇫🇴 🇦🇽" |
| 213 |
|
file_content = "test move file content 🇳🇴 😗 🇫🇴 🇦🇽" |
| 214 |
|
self.create_and_upload_file(file_name, file_content) |
| 215 |
|
|
| 216 |
|
# move file |
| 217 |
|
destination_path = "new_test_move_file_location 🇳🇴 😗 🇫🇴 🇦🇽" |
| 218 |
|
res = self.nxc_local.move_path(self.user_username, file_name, destination_path) |
| 219 |
|
assert res.is_ok |
| 220 |
|
assert res.raw.status_code == self.CREATED_CODE |
| 221 |
|
# check only new file exist |
| 222 |
|
original_file_props = self.nxc_local.list_folders(self.user_username, file_name) |
| 223 |
|
moved_file = self.nxc_local.list_folders(self.user_username, destination_path) |
| 224 |
|
assert original_file_props.data is None |
| 225 |
|
assert len(moved_file.data) == 1 |
| 226 |
|
|
| 227 |
|
# copy file to already exist location |
| 228 |
|
|
| 229 |
|
# create a file to move |
| 230 |
|
file_name = "test_move_file 🇳🇴 😗 🇫🇴 🇦🇽" |
| 231 |
|
file_content = "test move file content 🇳🇴 😗 🇫🇴 🇦🇽" |
| 232 |
|
self.create_and_upload_file(file_name, file_content) |
| 233 |
|
|
| 234 |
|
# create new file for conflict |
| 235 |
|
new_file_name = 'test_move_file_ 🇳🇴 😗 🇫🇴 🇦🇽' |
| 236 |
|
new_file_content = 'test_move_file_ 🇳🇴 😗 🇫🇴 🇦🇽' |
| 237 |
|
self.create_and_upload_file(new_file_name, new_file_content) |
| 238 |
|
|
| 239 |
|
# move file to the new file location |
| 240 |
|
res = self.nxc_local.move_path(self.user_username, file_name, new_file_name) |
| 241 |
|
assert not res.is_ok |
| 242 |
|
assert res.raw.status_code == self.PRECONDITION_FAILED_CODE |
| 243 |
|
# move with overriding |
| 244 |
|
res = self.nxc_local.move_path(self.user_username, file_name, new_file_name, overwrite=True) |
| 245 |
|
assert res.is_ok |
| 246 |
|
assert res.raw.status_code == self.NO_CONTENT_CODE |
| 247 |
|
|
| 248 |
|
# download just copied file and check content |
| 249 |
|
os.remove(os.path.join(os.getcwd(), new_file_name)) # remove file locally to download it |
| 250 |
|
self.nxc_local.download_file(self.user_username, new_file_name) |
| 251 |
|
with open(new_file_name, 'r') as f: |
| 252 |
|
downloaded_file_content = f.read() |
| 253 |
|
assert downloaded_file_content == file_content |
| 254 |
|
assert downloaded_file_content != new_file_content |
| 255 |
|
|
| 256 |
|
def test_set_list_favorites(self): |
| 257 |
|
# create new file to make favorite |
|
@@ 172-208 (lines=37) @@
|
| 169 |
|
assert res.raw.status_code == self.NOT_FOUND_CODE |
| 170 |
|
assert not res.is_ok |
| 171 |
|
|
| 172 |
|
def test_copy_path(self): |
| 173 |
|
# create a file to copy |
| 174 |
|
file_name = "test_file" |
| 175 |
|
file_content = "test file content" |
| 176 |
|
self.create_and_upload_file(file_name, file_content) |
| 177 |
|
|
| 178 |
|
# copy file |
| 179 |
|
destination_path = "new_test_file_location" |
| 180 |
|
res = self.nxc_local.copy_path(self.user_username, file_name, destination_path) |
| 181 |
|
assert res.raw.status_code == self.CREATED_CODE |
| 182 |
|
assert res.is_ok |
| 183 |
|
# check both file exist |
| 184 |
|
original_file_props = self.nxc_local.list_folders(self.user_username, file_name) |
| 185 |
|
copy_props = self.nxc_local.list_folders(self.user_username, destination_path) |
| 186 |
|
assert len(original_file_props.data) == 1 |
| 187 |
|
assert len(copy_props.data) == 1 |
| 188 |
|
|
| 189 |
|
# copy file to already exist location |
| 190 |
|
# create new file |
| 191 |
|
new_file_name = 'test_file_2' |
| 192 |
|
new_file_content = 'test_file_3' |
| 193 |
|
self.create_and_upload_file(new_file_name, new_file_content) |
| 194 |
|
res = self.nxc_local.copy_path(self.user_username, file_name, new_file_name) |
| 195 |
|
assert not res.is_ok |
| 196 |
|
assert res.raw.status_code == self.PRECONDITION_FAILED_CODE |
| 197 |
|
# copy with overriding |
| 198 |
|
res = self.nxc_local.copy_path(self.user_username, file_name, new_file_name, overwrite=True) |
| 199 |
|
assert res.is_ok |
| 200 |
|
assert res.raw.status_code == self.NO_CONTENT_CODE |
| 201 |
|
|
| 202 |
|
# download just copied file and check content |
| 203 |
|
os.remove(os.path.join(os.getcwd(), new_file_name)) # remove file locally to download it |
| 204 |
|
self.nxc_local.download_file(self.user_username, new_file_name) |
| 205 |
|
with open(new_file_name, 'r') as f: |
| 206 |
|
downloaded_file_content = f.read() |
| 207 |
|
assert downloaded_file_content == file_content |
| 208 |
|
assert downloaded_file_content != new_file_content |
| 209 |
|
|
| 210 |
|
def test_move_path(self): |
| 211 |
|
# create a file to move |