mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Testing more file moves.
This commit is contained in:
parent
6f1431e6e4
commit
ea4d640100
1 changed files with 22 additions and 0 deletions
|
|
@ -515,6 +515,7 @@ async def test_directory_crud(test_session, test_async_client, test_directory, a
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_move(test_session, test_directory, make_files_structure, test_async_client):
|
||||
"""Files can be moved up and down the media directory. Destination directories should already exist."""
|
||||
baz, bar = make_files_structure({
|
||||
'foo/bar.txt': 'bar',
|
||||
'baz.txt': 'baz',
|
||||
|
|
@ -526,6 +527,7 @@ async def test_move(test_session, test_directory, make_files_structure, test_asy
|
|||
assert response.status_code == HTTPStatus.NOT_FOUND
|
||||
|
||||
(test_directory / 'qux').mkdir()
|
||||
(test_directory / 'quux/quuz').mkdir(parents=True)
|
||||
|
||||
# mv foo baz.txt qux
|
||||
content = dict(paths=['foo', 'baz.txt'], destination='qux')
|
||||
|
|
@ -542,6 +544,26 @@ async def test_move(test_session, test_directory, make_files_structure, test_asy
|
|||
assert (test_directory / 'qux/bar.txt').is_file()
|
||||
assert (test_directory / 'qux/foo').is_dir()
|
||||
|
||||
# mv qux/bar.txt ./
|
||||
content = dict(paths=['qux/bar.txt', ], destination='')
|
||||
request, response = await test_async_client.post('/api/files/move', json=content)
|
||||
assert response.status_code == HTTPStatus.NO_CONTENT
|
||||
assert (test_directory / 'bar.txt').is_file()
|
||||
|
||||
# mv bar.txt quux/quuz/bar.txt
|
||||
content = dict(paths=['bar.txt', ], destination='quux/quuz')
|
||||
request, response = await test_async_client.post('/api/files/move', json=content)
|
||||
assert response.status_code == HTTPStatus.NO_CONTENT
|
||||
assert (test_directory / 'quux/quuz/bar.txt').is_file()
|
||||
|
||||
# mv quux/quuz/bar.txt quux/bar.txt
|
||||
content = dict(paths=['quux/quuz/bar.txt', ], destination='quux')
|
||||
request, response = await test_async_client.post('/api/files/move', json=content)
|
||||
assert response.status_code == HTTPStatus.NO_CONTENT
|
||||
assert (test_directory / 'quux/bar.txt').is_file()
|
||||
assert (test_directory / 'qux/foo').is_dir()
|
||||
assert (test_directory / 'quux/quuz').is_dir()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_rename_file(test_session, test_directory, make_files_structure, test_async_client):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue