Skip to content

Commit

Permalink
sync etag returned from move (#2304)
Browse files Browse the repository at this point in the history
to match the updated item etag

SDESK-6319
  • Loading branch information
petrjasek authored Dec 7, 2021
1 parent 4c832dc commit 4861a22
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions apps/duplication/archive_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ def move_content(self, id, doc):
# finally apply any on stage rules/macros
apply_onstage_rule(archived_doc, id)

# return etag of modified item
doc["_etag"] = archived_doc["_etag"]

return archived_doc

def _move(self, archived_doc, doc):
Expand Down
4 changes: 2 additions & 2 deletions features/content_move.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Feature: Move or Send Content to another desk
[{"guid": "123", "type":"text", "headline": "test1", "guid": "123", "state": "draft", "task": {"user": "#CONTEXT_USER_ID#"}, "versioncreated": "2020-01-01T10:00:00+0000"}]
"""
When we get "/archive/123"
And we save etag
And we post to "/archive/123/move"
"""
[{"task": {"desk": "#desks._id#", "stage": "#desks.incoming_stage#"}}]
"""
Then we get OK response
And we save etag
And we get notifications
"""
[
Expand All @@ -43,7 +43,7 @@ Feature: Move or Send Content to another desk
"""
Then there is no "last_production_desk" in task
And there is no "last_authoring_desk" in task
And we get different etag
And we get matching etag

@auth
@notification
Expand Down
4 changes: 2 additions & 2 deletions features/packages.feature
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ Feature: Packages
"""
[{"guid": "tag:example.com,0000:newsml_BRE9A679", "headline": "test"}]
"""
And we save etag
Then we save etag
When we post to "archive" with success
"""
{
Expand Down Expand Up @@ -809,7 +809,7 @@ Feature: Packages
"""
{"headline": "test", "linked_in_packages": []}
"""
And we get same etag
And we get matching etag


@auth
Expand Down
9 changes: 6 additions & 3 deletions superdesk/tests/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,14 +752,17 @@ def get_response_etag(response):
return json.loads(response.get_data())["_etag"]


@when("we save etag")
@then("we save etag")
def step_when_we_save_etag(context):
context.etag = get_response_etag(context.response)


@then("we get same etag")
@then("we get matching etag")
def step_then_we_get_same_etag(context):
assert context.etag == get_response_etag(context.response), "etags not matching"
assert context.etag == get_response_etag(context.response), "etags not matching %s != %s" % (
context.etag,
get_response_etag(context.response),
)


@then("we get different etag")
Expand Down
1 change: 0 additions & 1 deletion superdesk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def gen_password(lenght=PWD_DEFAULT_LENGHT):
sys_random = SystemRandom()
return "".join(sys_random.choice(PWD_ALPHABET) for _ in range(lenght))


else:
# "secrets" module is only available with Python 3.6+
import secrets
Expand Down

0 comments on commit 4861a22

Please sign in to comment.