Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/support/2.4' into release/2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjasek committed Nov 16, 2022
2 parents e9adb31 + cc6abaf commit c12a5ee
Show file tree
Hide file tree
Showing 21 changed files with 157 additions and 163 deletions.
127 changes: 33 additions & 94 deletions .github/workflows/nose-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,147 +3,86 @@ name: "Test"
on: [push, pull_request]

jobs:
nose:
pytest:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.8]
python-version: ['3.8', '3.10']

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install packages
run: ./scripts/tests_setup

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('dev-requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip
${{ runner.os }}-
- name: Install dependencies
run: |
python -m pip install --upgrade 'pip<21.3' wheel setuptools
pip install -r dev-requirements.txt
- run: ./scripts/tests_setup
- run: pip install -U pip wheel setuptools
- run: pip install -r dev-requirements.txt

- name: Nosetests
run: nosetests --logging-level=ERROR
- run: pytest --log-level=ERROR --disable-warnings

behave:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.8]
python-version: ['3.8', '3.10']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install packages
run: ./scripts/tests_setup

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('dev-requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip
${{ runner.os }}-
- name: Install dependencies
run: |
python -m pip install --upgrade 'pip<21.3' wheel setuptools
pip install -r dev-requirements.txt
- run: ./scripts/tests_setup
- run: pip install -U pip wheel setuptools
- run: pip install -r dev-requirements.txt

- name: Behave
run: behave --tags=-sams --format progress2 --logging-level=ERROR
- run: behave --tags=-sams --format progress2 --logging-level=ERROR

behave-sams:

runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.8]
python-version: ['3.8', '3.10']

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install packages
run: ./scripts/tests_setup
- uses: actions/checkout@v3

- name: Start SAMS
run: ./scripts/install-start-sams
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('dev-requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip
${{ runner.os }}-
- run: ./scripts/tests_setup
- run: ./scripts/install-start-sams

- name: Install dependencies
run: |
python -m pip install --upgrade 'pip<21.3' wheel setuptools
pip install -r dev-requirements.txt
- run: pip install -U pip wheel setuptools
- run: pip install -r dev-requirements.txt

- name: Behave
run: behave --tags=sams --format progress2 --logging-level=ERROR
- run: behave --tags=sams --format progress2 --logging-level=ERROR

prodapi:

runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.8]
python-version: ['3.8', '3.10']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install packages
run: ./scripts/tests_setup
- run: ./scripts/tests_setup
- run: pip install -U pip wheel setuptools
- run: pip install -r dev-requirements.txt

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('dev-requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip
${{ runner.os }}-
- name: Install dependencies
run: |
python -m pip install --upgrade 'pip<21.3' wheel setuptools
pip install -r dev-requirements.txt
- name: prodapi-pytest
run: cd prod_api && time pytest
- run: pytest prod_api

16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Superdesk Server Changelog

## [2.4.5] 2022-11-16

## Bug

### [SDESK-6662](https://sofab.atlassian.net/browse/SDESK-6662) PNG image upload fails \(EWTN\)

### [SDESK-6675](https://sofab.atlassian.net/browse/SDESK-6675) Unable to unlock article \(EWTN\)

### [SDESK-6707](https://sofab.atlassian.net/browse/SDESK-6707) fix empty description in ninjs when abstract is present

[Changes](https://github.com/superdesk/superdesk-core/milestone/130?closed=1)

## [2.4.4] 2022-10-19

[Changes](https://github.com/superdesk/superdesk-core/milestone/129?closed=1)

## [2.5.1] 2022-10-17

[Changes](https://github.com/superdesk/superdesk-core/milestone/127?closed=1)
Expand Down
2 changes: 1 addition & 1 deletion apps/archive/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ def _validate_updates(self, original, updates, user):

update_schedule_settings(updated, PUBLISH_SCHEDULE, updated.get(PUBLISH_SCHEDULE))

if updates.get(PUBLISH_SCHEDULE) and updates.get("state") != CONTENT_STATE.PUBLISHED:
if updates.get(PUBLISH_SCHEDULE) and updates.get("state") != CONTENT_STATE.PUBLISHED and not force_unlock:
validate_schedule(updated.get(SCHEDULE_SETTINGS, {}).get("utc_{}".format(PUBLISH_SCHEDULE)))

updates[SCHEDULE_SETTINGS] = updated.get(SCHEDULE_SETTINGS, {})
Expand Down
2 changes: 1 addition & 1 deletion apps/item_lock/components/item_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def unlock(self, item_filter, user_id, session_id, etag):
push_content_notification([item])
else:
updates = {}
set_unlock_updates(updates)
set_unlock_updates(updates, True)
autosave = superdesk.get_resource_service("archive_autosave").find_one(req=None, _id=item["_id"])
if autosave and item[ITEM_STATE] not in PUBLISH_STATES:
if not hasattr(flask.g, "user"): # user is not set when session expires
Expand Down
21 changes: 18 additions & 3 deletions apps/publish/content/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,9 +854,11 @@ def _publish_associated_items(self, original, updates=None):
# if main item is scheduled we must also schedule associations
self._inherit_publish_schedule(original, updates, associated_item)

associated_item_updates = associated_item.copy()
get_resource_service("archive_publish").patch(
id=associated_item.pop(config.ID_FIELD), updates=associated_item
id=associated_item[config.ID_FIELD], updates=associated_item_updates
)
sync_associated_item_changes(associated_item, associated_item_updates)
associated_item["state"] = updates.get("state", self.published_state)
associated_item["operation"] = self.publish_type
updates[ASSOCIATIONS] = updates.get(ASSOCIATIONS, {})
Expand All @@ -874,13 +876,15 @@ def _publish_associated_items(self, original, updates=None):
# there is no update for this item
associated_item.get("task", {}).pop("stage", None)
remove_unwanted(associated_item)
publish_service.patch(id=associated_item.pop(config.ID_FIELD), updates=associated_item)
associated_item_updates = associated_item.copy()
publish_service.patch(id=associated_item[config.ID_FIELD], updates=associated_item_updates)
sync_associated_item_changes(associated_item, associated_item_updates)
continue

if association_updates.get("state") not in PUBLISH_STATES:
# There's an update to the published associated item
remove_unwanted(association_updates)
publish_service.patch(id=association_updates.pop(config.ID_FIELD), updates=association_updates)
publish_service.patch(id=associated_item[config.ID_FIELD], updates=association_updates)

# When there is an associated item which is published, Inserts the latest version of that associated item into archive_versions.
insert_into_versions(doc=associated_item)
Expand Down Expand Up @@ -936,6 +940,17 @@ def update_item_data(item, data, keys=None, keep_existing=False):
item[key] = data[key]


def sync_associated_item_changes(associated_item, updates):
"""Sync changes to the associated item reference after publishing the item.
We want to get there all system changes, but not content fields which would
override local changes done on the association.
"""
for key in updates:
if key not in DEFAULT_SCHEMA.keys() and updates.get(key):
associated_item[key] = updates[key]


superdesk.workflow_state("published")
superdesk.workflow_action(
name="publish",
Expand Down
1 change: 0 additions & 1 deletion content_api/behave_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def get_test_settings():
test_settings["CONTENTAPI_ELASTICSEARCH_INDEX"] = TEST_DBNAME
test_settings["MONGO_DBNAME"] = TEST_DBNAME
test_settings["MONGO_URI"] = "mongodb://localhost/%s" % TEST_DBNAME
test_settings["DEBUG"] = True
test_settings["TESTING"] = True
test_settings["SUPERDESK_TESTING"] = True
test_settings["CONTENT_EXPIRY_MINUTES"] = 99
Expand Down
7 changes: 3 additions & 4 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
flake8
flake8-bugbear
flake8-docstrings
flake8-bugbear==19.8.0
nose
nose-exclude
pep8
pyflakes
pydocstyle<4.0
Expand All @@ -11,8 +10,8 @@ watchdog==0.9.0
wooper==0.4.4
requests-mock==1.8.0
responses
pytest==5.2.2
pytest-env==0.6.2
pytest
pytest-env
python3-saml>=1.9,<1.10
typing_extensions>=3.7.4
moto[sqs]
Expand Down
25 changes: 25 additions & 0 deletions features/content_lock.feature
Original file line number Diff line number Diff line change
Expand Up @@ -452,3 +452,28 @@ Feature: Content Locking

When we get "/workqueue"
Then we get list with 0 items

@auth
Scenario: Unlocking an item with earlier publish schedule
Given "archive"
"""
[{"_id": "item-1", "guid": "item-1", "headline": "test", "_current_version": 1}]
"""

When we post to "archive_autosave"
"""
{"_id": "item-1", "guid": "item-1", "publish_schedule": "2021-06-06T13:25:00+0000"}
"""
Then we get ok response

When we post to "/archive/item-1/lock"
"""
{}
"""
Then we get ok response

When we post to "/archive/item-1/unlock"
"""
{}
"""
Then we get ok response
8 changes: 5 additions & 3 deletions features/content_publish.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2645,7 +2645,7 @@ Feature: Content Publishing
{
"guid": "234", "type": "picture", "slugline": "234", "headline": "234", "state": "in_progress",
"task": {"desk": "#desks._id#", "stage": "#desks.incoming_stage#", "user": "#CONTEXT_USER_ID#"},
"renditions": {}
"renditions": {}, "byline": "original byline"
},
{
"guid": "123", "type": "text", "headline": "test", "state": "in_progress", "profile": "profile1",
Expand All @@ -2664,7 +2664,8 @@ Feature: Content Publishing
"subject": [{"name": "subject", "parent": "05000000", "qcode": "05007000"}],
"anpa_category": [{"qcode": "category", "name": "categories"}],
"renditions": {},
"task": {"desk": "#desks._id#", "stage": "#desks.incoming_stage#", "user": "#CONTEXT_USER_ID#"}
"task": {"desk": "#desks._id#", "stage": "#desks.incoming_stage#", "user": "#CONTEXT_USER_ID#"},
"byline": ""
},
"related--1": {
"_id": "text",
Expand All @@ -2686,7 +2687,8 @@ Feature: Content Publishing
"associations": {
"media--1": {
"state": "published",
"task": {"desk": "#desks._id#", "stage": "#desks.incoming_stage#"}
"task": {"desk": "#desks._id#", "stage": "#desks.incoming_stage#"},
"byline": ""
}
},
"task":{"desk": "#desks._id#", "stage": "#desks.incoming_stage#"}
Expand Down
1 change: 0 additions & 1 deletion prod_api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def get_test_prodapi_app(extra_config=None):
:return: eve.flaskapp.Eve
"""
test_config = {
"DEBUG": True,
"TESTING": True,
"SUPERDESK_TESTING": True,
"MONGO_CONNECT": False,
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.black]
line-length = 120
target-version = ['py36']
target-version = ['py38']
include = '\.py$'
exclude = '''
(
Expand All @@ -15,3 +15,7 @@ exclude = '''
| env
)
'''

[tool.pytest.ini_options]
testpaths = ["tests", "superdesk", "apps"]
python_files = "*_test.py *_tests.py test_*.py tests_*.py tests.py test.py"
Loading

0 comments on commit c12a5ee

Please sign in to comment.