Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/uat' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjasek committed Apr 17, 2024
2 parents dc652d0 + 1998976 commit 6268e42
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 31 deletions.
5 changes: 1 addition & 4 deletions server/cp/output/formatter/ninjs_formatter_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,17 +423,14 @@ def _get_type(self, article):
return CONTENT_TYPE.TEXT
return article[ITEM_TYPE]

# Added an updated _get_associations method

# Updated _get_association to work with both Pictures and Text

def _get_associations(self, article, subscriber):
associations = {}
article_type = self._get_type(article)

if article_type == "text":
for key, value in article.get("associations", {}).items():
if "_id" in value:
if value and "_id" in value:
associations[key] = {"guid": value["_id"]}

return associations
Expand Down
46 changes: 19 additions & 27 deletions server/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,16 @@ blinker==1.4
# flask-mail
# raven
# superdesk-core
boto3==1.34.41
boto3==1.34.72
# via superdesk-core
botocore==1.34.41
botocore==1.34.72
# via
# boto3
# s3transfer
cachetools==5.3.2
cachetools==5.3.3
# via flask-oidc-ex
celery[redis]==5.2.7
# via
# celery
# superdesk-core
# via superdesk-core
cerberus==1.3.5
# via
# eve
Expand All @@ -64,15 +62,15 @@ click==8.1.7
# click-plugins
# click-repl
# flask
click-didyoumean==0.3.0
click-didyoumean==0.3.1
# via celery
click-plugins==1.1.1
# via celery
click-repl==0.3.0
# via celery
croniter==0.3.37
# via superdesk-core
cryptography==42.0.2
cryptography==42.0.5
# via
# authlib
# jwcrypto
Expand All @@ -81,15 +79,11 @@ deepdiff==6.7.1
docopt==0.6.2
# via num2words
draftjs-exporter[lxml]==2.1.7
# via
# draftjs-exporter
# superdesk-core
# via superdesk-core
ecs-logging==2.1.0
# via elastic-apm
elastic-apm[flask]==6.20.0
# via
# elastic-apm
# superdesk-core
elastic-apm[flask]==6.21.4.post8347027212
# via superdesk-core
elasticsearch==7.13.4
# via eve-elastic
eve==1.1.2
Expand Down Expand Up @@ -117,7 +111,7 @@ flask-oidc-ex==0.5.5
# via superdesk-core
flask-script==2.0.6
# via superdesk-core
future==0.18.3
future==1.0.0
# via python-twitter
gunicorn==21.2.0
# via -r requirements.in
Expand Down Expand Up @@ -149,7 +143,7 @@ jmespath==1.0.1
# via
# boto3
# botocore
jwcrypto==1.5.4
jwcrypto==1.5.6
# via
# flask-oidc-ex
# python-jwt
Expand Down Expand Up @@ -181,19 +175,19 @@ oauthlib==3.2.2
# via requests-oauthlib
ordered-set==4.1.0
# via deepdiff
packaging==23.2
packaging==24.0
# via gunicorn
pillow==9.2.0
# via superdesk-core
prompt-toolkit==3.0.43
# via click-repl
pyasn1==0.5.1
pyasn1==0.6.0
# via
# ldap3
# oauth2client
# pyasn1-modules
# rsa
pyasn1-modules==0.3.0
pyasn1-modules==0.4.0
# via oauth2client
pycparser==2.21
# via cffi
Expand All @@ -202,7 +196,7 @@ pymongo==3.11.4
# eve
# mongolock
# superdesk-core
pyparsing==3.1.1
pyparsing==3.1.2
# via httplib2
python-dateutil==2.7.5
# via
Expand Down Expand Up @@ -233,9 +227,7 @@ pytz==2024.1
pyyaml==6.0.1
# via superdesk-core
raven[flask]==6.10.0
# via
# raven
# superdesk-core
# via superdesk-core
redis==4.5.5
# via
# celery
Expand All @@ -247,11 +239,11 @@ requests==2.31.0
# python-twitter
# requests-oauthlib
# superdesk-core
requests-oauthlib==1.3.1
requests-oauthlib==2.0.0
# via python-twitter
rsa==4.9
# via oauth2client
s3transfer==0.10.0
s3transfer==0.10.1
# via boto3
sgmllib3k==1.0.0
# via feedparser
Expand All @@ -270,7 +262,7 @@ superdesk-core @ git+https://github.com/superdesk/superdesk-core.git@hotfix/2.6.
# via -r requirements.in
superdesk-planning @ git+https://github.com/superdesk/superdesk-planning.git@hotfix/2.6.3
# via -r requirements.in
typing-extensions==4.9.0
typing-extensions==4.10.0
# via
# jwcrypto
# superdesk-core
Expand Down
28 changes: 28 additions & 0 deletions server/tests/output/formatter/test_ninjs_formatter_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import unittest

from cp.output.formatter.ninjs_formatter_2 import NINJSFormatter_2


class TestNinjsFormatter(unittest.TestCase):
def setUp(self):
self.formatter = NINJSFormatter_2()

def test_get_associations_text(self):
# Test case for article type "text"
article = {
"type": "text",
"associations": {
"key1": {"_id": "value1"},
"key2": {"_id": "value2"},
"key3": {"_id": "value3"},
"key4": None,
},
}
expected_result = {
"key1": {"guid": "value1"},
"key2": {"guid": "value2"},
"key3": {"guid": "value3"},
}

result = self.formatter._get_associations(article, {})
self.assertEqual(result, expected_result)

0 comments on commit 6268e42

Please sign in to comment.