Skip to content

Commit

Permalink
tests: dropzone_add test
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Feb 21, 2024
1 parent 568a9e5 commit e7e5340
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions web/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,8 @@ def cloud_service_response(mocker, webdav_server, request):
elif "no_scheme" in request.keywords:
scheme = ""
return CloudTokenResponse(nc_locator=f"{scheme}cloud-auth-serv.ice")


@pytest.fixture
def jpg_file_content():
return b"\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00H\x00H\x00\x00\xff\xdb\x00C\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\x0b\x08\x00\x01\x00\x01\x01\x01\x11\x00\xff\xc4\x00\x14\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x08\x01\x01\x00\x01?\x10"
22 changes: 22 additions & 0 deletions web/tests/meeting/test_meeting_files.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from flask import url_for
from webdav3.exceptions import WebDavException

Expand Down Expand Up @@ -42,3 +44,23 @@ def test_file_sharing_disabled(client_app, authenticated_user, meeting):
url_for("meeting_files.edit_meeting_files", meeting=meeting), status=302
)
assert ("warning", "Vous ne pouvez pas modifier cet élément") in res.flashes


def test_add_dropzone_file(
client_app, authenticated_user, meeting, jpg_file_content, tmp_path
):
res = client_app.post(
"/meeting/files/1/dropzone",
{
"dzchunkindex": 0,
"dzchunkbyteoffset": 0,
"dztotalchunkcount": 1,
"dztotalfilesize": 134,
},
upload_files=[("dropzoneFiles", "file.jpg", jpg_file_content)],
)

assert res.text == "Chunk upload successful"

with open(os.path.join(tmp_path, "dropzone", "1-1-file.jpg"), "rb") as fd:
assert jpg_file_content == fd.read()

0 comments on commit e7e5340

Please sign in to comment.