Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync etag returned from move #2304

Merged
merged 1 commit into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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