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

syndicate API including currently RSS and ATOM formatter API #1188

Open
wants to merge 63 commits into
base: lockhart
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
5b4e71c
update version for the https://sofab.atlassian.net/browse/SDAN-726
rbi-aap Apr 9, 2024
d2ebb0d
update for fix building error
rbi-aap Apr 9, 2024
beae01e
update for building error
rbi-aap Apr 9, 2024
d9f036c
update for review
rbi-aap Apr 9, 2024
c3217fe
update from review feedback regarding naming convention from audioIf …
rbi-aap Apr 11, 2024
b19a074
update for review
rbi-aap Apr 11, 2024
6433e61
remove space
rbi-aap Apr 11, 2024
41fcac4
remove space line
rbi-aap Apr 11, 2024
72f4876
Merge branch 'superdesk:lockhart' into lockhart
rbi-aap May 31, 2024
5f58d87
syndicate API. including RSS and ATOM formatter
rbi-aap May 31, 2024
43eb8c0
update style
rbi-aap May 31, 2024
cf5bcfa
split the 125 long line
rbi-aap Jun 3, 2024
391cf09
keep same name
rbi-aap Jun 3, 2024
a968773
update for review and feedback
rbi-aap Jun 7, 2024
9fa50f7
update for line long issues
rbi-aap Jun 7, 2024
f341ed5
for line long
rbi-aap Jun 7, 2024
165cc8a
for orderdict error in test
rbi-aap Jun 7, 2024
73a0b14
for behave test
rbi-aap Jun 7, 2024
fcf0f01
update
rbi-aap Jun 7, 2024
6a36641
add regular expression in route for avoid conflicts with old API
rbi-aap Jun 11, 2024
87c3098
update for the review
rbi-aap Jul 15, 2024
c3be21b
update for review
rbi-aap Jul 17, 2024
b826fb4
update for review
rbi-aap Jul 17, 2024
520fb03
for block-content SDAN-728 and SDAN-731
rbi-aap Jul 26, 2024
31a2437
for sync
rbi-aap Jul 26, 2024
dca96c4
replace await with promise
rbi-aap Jul 26, 2024
e5e4d15
for review
rbi-aap Jul 26, 2024
bc4ca05
for style
rbi-aap Jul 26, 2024
6d1803d
update after unit test for review
rbi-aap Aug 2, 2024
5ae6bd9
update for flake8
rbi-aap Aug 2, 2024
996dfe6
update for review
rbi-aap Aug 2, 2024
5fad329
for unit test
rbi-aap Aug 2, 2024
8bc3bc9
for test only
rbi-aap Aug 2, 2024
a46d813
temp turn off test_bookmarks test not relavant to content block
rbi-aap Aug 2, 2024
7200041
test
rbi-aap Aug 2, 2024
706d14d
test
rbi-aap Aug 6, 2024
750035a
for mock get_user in test
rbi-aap Aug 6, 2024
724c74c
for front end
rbi-aap Aug 30, 2024
d326f8d
ArticleBodyHTML.jsx -add XSS attach prevent and video player improvement
rbi-aap Aug 30, 2024
abe2ad0
update incorrect icon
rbi-aap Aug 30, 2024
4ccdc0b
update for env
rbi-aap Sep 2, 2024
68bd3d2
update
rbi-aap Sep 2, 2024
67a48d6
for env update
rbi-aap Sep 2, 2024
980c47e
for env change
rbi-aap Sep 2, 2024
b847be9
update env
rbi-aap Sep 2, 2024
565b8de
update
rbi-aap Sep 2, 2024
ef16577
update
rbi-aap Sep 2, 2024
f2e546b
update
rbi-aap Sep 2, 2024
141d3e9
update for old failed test
rbi-aap Sep 3, 2024
ae47ffc
update for a test
rbi-aap Sep 3, 2024
5bcacde
update for check
rbi-aap Sep 3, 2024
3ec72ba
change user type
rbi-aap Sep 3, 2024
80a288a
update for feature test
rbi-aap Sep 3, 2024
7204aee
block_media
rbi-aap Sep 3, 2024
49c403f
update for unit_test block_media
rbi-aap Sep 3, 2024
aaa1e17
update a few features near to release
rbi-aap Sep 3, 2024
a1d2243
lint check for indent
rbi-aap Sep 3, 2024
8d7a608
Enhanced video loading and poster management, updated Webpack and pac…
rbi-aap Sep 10, 2024
f1ee3c5
for update the ESLint for webpack and React
rbi-aap Sep 10, 2024
bb82ebe
for images.js to manage images in Webpack
rbi-aap Sep 10, 2024
1019cb7
for review update
rbi-aap Sep 13, 2024
61e88d5
remove memory monitoring function in live repo
rbi-aap Sep 16, 2024
7dc8049
check the reason
rbi-aap Sep 16, 2024
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
162 changes: 162 additions & 0 deletions features/news_api_syndicate.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
Feature: News API Syndicate ATOM Search

Background: Initial setup
Given "companies"
"""
[{"name": "Test Company", "is_enabled" : true}]
"""
Given "news_api_tokens"
"""
[{"company" : "#companies._id#", "enabled" : true}]
"""
When we save API token

Scenario: Test atom of syndicate request response restricted by product
Given "items"
"""
[{"body_html": "Once upon a time there was a fish who could swim", "headline": "headline 1",
"firstpublished": "#DATE-1#", "versioncreated": "#DATE#"},
{"body_html": "Once upon a time there was a aardvark that could not swim", "headline": "headline 2",
"firstpublished": "#DATE-1#", "versioncreated": "#DATE#"}]
"""
Given "products"
"""
[{"name": "A fishy Product",
"decsription": "a product for those interested in fish",
"companies" : [
"#companies._id#"
],
"query": "fish",
"product_type": "news_api"
}]
"""
When we get "syndicate?formatter=atom"
Then we get OK response
Then we "get" "<title><![CDATA[headline 1]]></title>" in syndicate xml response
Then we "don't get" "<title><![CDATA[headline 2]]></title>" in syndicate xml response

Scenario: test syndicate atom request search q
Given "items"
"""
[{"body_html": "<p>Once upon a time there was a monkey who could swim</p>", "headline": "headline 1",
"byline": "S Smith", "pubstatus": "usable", "service" : [{"name" : "Australian General News", "code" : "a"}],
"description_text": "summary",
"associations" : {
"featuremedia" : {
"mimetype" : "image/jpeg",
"description_text" : "Deputy Prime Minister Michael McCormack during Question Time",
"version" : "1",
"byline" : "Mick Tsikas/AAP PHOTOS",
"body_text" : "QUESTION TIME ALT",
"renditions" : {
"16-9" : {
"href" : "/assets/5fc5dce16369ab07be3325fa",
"height" : 720,
"width" : 1280,
"media" : "5fc5dce16369ab07be3325fa",
"poi" : {
"x" : 453,
"y" : 335
},
"mimetype" : "image/jpeg"
}
}
}},
"firstpublished": "#DATE-1#", "versioncreated": "#DATE#"}]
"""
When we get "syndicate?formatter=atom&q=monkey"
Then we get OK response
Then we "get" "<title><![CDATA[headline 1]]></title>" in syndicate xml response
Then we "get" "<media:credit>Mick Tsikas/AAP PHOTOS</media:credit>" in syndicate xml response

Scenario: test atom request with embedded image
Given "products"
"""
[{"name": "A fishy Product",
"decsription": "a product for those interested in fish",
"companies" : [
"#companies._id#"
],
"query": "fish",
"product_type": "news_api"
},
{"name": "A pic product",
"decsription": "pic product",
"companies" : [
"#companies._id#"
],
"query": "",
"sd_product_id": "1",
"product_type": "news_api"
}]
"""
Given "items"
"""
[{"body_html": "<p>Once upon a time there was a fish who could swim</p><!-- EMBED START Image {id: \"editor_19\"} --><figure><img src=\"somthing\" alt=\"alt text\" id=\"editor_19\"<figcaption>Some caption</figcaption></figure><!-- EMBED END Image {id: \"editor_19\"} -->",
"headline": "headline 1",
"byline": "S Smith", "pubstatus": "usable", "service" : [{"name" : "Australian General News", "code" : "a"}],
"description_text": "summary",
"associations" : {
"editor_19" : {
"mimetype" : "image/jpeg",
"description_text" : "Deputy Prime Minister Michael McCormack during Question Time",
"version" : "1",
"byline" : "Mick Tsikas/AAP PHOTOS",
"body_text" : "QUESTION TIME ALT",
"products": [{"code": "1"}],
"renditions" : {
"16-9" : {
"href" : "/assets/5fc5dce16369ab07be3325fa",
"height" : 720,
"width" : 1280,
"media" : "5fc5dce16369ab07be3325fa",
"poi" : {
"x" : 453,
"y" : 335
},
"mimetype" : "image/jpeg"
}
}
}},
"firstpublished": "#DATE-1#", "versioncreated": "#DATE#"}]
"""
When we get "syndicate?formatter=atom"
Then we get OK response
Then we "get" "<title><![CDATA[headline 1]]></title>" in syndicate xml response
Then we "get" "5fc5dce16369ab07be3325fa" in atom xml response
Then we "get" "src="http://" in atom xml response

Scenario: Atom request response restricted by featured image product
Given "items"
"""
[{"body_html": "Once upon a time there was a fish who could swim", "headline": "headline 1",
"firstpublished": "#DATE-1#", "versioncreated": "#DATE#",
"associations": {"featuremedia": {"products": [{"code": "1234"}], "renditions": {"original": {}} }}},
{"body_html": "Once upon a time there was a aardvark that could not swim", "headline": "headline 2",
"firstpublished": "#DATE-1#", "versioncreated": "#DATE#",
"associations": {"featuremedia": {"products": [{"code": "4321"}], "renditions": {"original": {}} }}}]
"""
Given "products"
"""
[{"name": "A fishy Product",
"decsription": "a product for those interested in fish",
"companies" : [
"#companies._id#"
],
"query": "Once upon a time",
"product_type": "news_api"
},
{"name": "A fishy superdesk product",
"description": "a superdesk product restricting images in the atom feed",
"companies" : [
"#companies._id#"
],
"sd_product_id": "1234",
"product_type": "news_api"
}
]
"""
When we get "syndicate?formatter=atom"
Then we get OK response
Then we "get" "<title><![CDATA[headline 1]]></title>" in syndicate xml response
Then we "don't get" "<title><![CDATA[headline 2]]></title>" in syndicate xml response
19 changes: 19 additions & 0 deletions features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from wooper.general import (
get_body
)
import logging


@when('we save API token')
Expand Down Expand Up @@ -74,3 +75,21 @@ def we_get_text_in_atom_xml_response(context, get, text):
assert (text in get_body(context.response))
else:
assert (text not in get_body(context.response))


@then('we "{get}" "{text}" in syndicate xml response')
def we_get_text_in_syndicate_xml_response(context, get, text):
with context.app.test_request_context(context.app.config['URL_PREFIX']):
response_body = get_body(context.response)
logging.info("Response body: %s", response_body)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be good only for debugging purposes, otherwise it unnecessarily adds to the output when running tests. You can, however, add the response_body as a msg in the assert statement upon failure

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this log entry, not needed. You can instead add this to the assert statement, so it shows in the console IF this step fails

assert (isinstance(get_body(context.response), str))
try:
tree = lxml.etree.fromstring(response_body.encode('utf-8'))
assert '{http://www.w3.org/2005/Atom}feed' == tree.tag
if get == 'get':
assert (text in response_body)
else:
assert (text not in response_body)
except lxml.etree.XMLSyntaxError as e:
logging.error("XML parsing error: %s", e)
raise AssertionError("Response is not valid XML")
157 changes: 0 additions & 157 deletions newsroom/news_api/news/atom/atom.py

This file was deleted.

Loading
Loading