Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
madwort committed Jun 26, 2024
1 parent 0b34341 commit 7cbc9ba
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion airlock/business_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ def update_file_in_request(
!= WorkspaceFileState.CONTENT_UPDATED
):
raise self.RequestPermissionDenied(
f"Cannot update file in request if it is not updated on disk"
"Cannot update file in request if it is not updated on disk"
)

src = workspace.abspath(relpath)
Expand Down
4 changes: 2 additions & 2 deletions airlock/views/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ def workspace_add_file_to_request(request, workspace_name):
bll.update_file_in_request(
release_request, relpath, request.user, group_name, filetype
)
except bll.APIException as err: # pragma: no cover
# it's pretty difficult to hit this error
except bll.APIException as err: # pragma: no cover
# it's pretty difficult to hit this error
msgs.append(f"{relpath}: {err}")
else:
success = True
Expand Down
33 changes: 33 additions & 0 deletions tests/unit/test_business_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,39 @@ def test_add_file_to_request_states(
bll.add_file_to_request(release_request, path, author)


def test_workspace_request_file_request_updated_exception(airlock_client, bll):
airlock_client.login(workspaces=["test1"])

workspace = factories.create_workspace("test1")
factories.write_workspace_file(workspace, "test/path.txt")
release_request = factories.create_release_request(workspace, airlock_client.user)
factories.write_request_file(release_request, "test", "path")
assert len(release_request.filegroups) == 1

response = airlock_client.post(
"/workspaces/add-file-to-request/test1",
data={
"form-TOTAL_FORMS": "1",
"form-INITIAL_FORMS": "1",
"form-0-file": "test/path.txt",
"form-0-filetype": "OUTPUT",
"filegroup": "default",
"next_url": workspace.get_url("test/path.txt"),
},
)
assert response.status_code == 302
assert workspace.get_url("test/path.txt") in response.headers["Location"]

current_release_request = bll.get_current_request(
workspace.name, airlock_client.user
)
assert current_release_request.id == release_request.id
assert current_release_request.abspath("default/test/path.txt").exists()
filegroup = current_release_request.filegroups["default"]
assert filegroup.name == "default"
assert UrlPath("test/path.txt") in filegroup.files


def test_add_file_to_request_default_filetype(bll):
author = factories.create_user(username="author", workspaces=["workspace"])
path = UrlPath("path/file.txt")
Expand Down

0 comments on commit 7cbc9ba

Please sign in to comment.