-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add relevance to cp ninjs output (#239)
SDCP-714
- Loading branch information
Showing
9 changed files
with
89 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import flask | ||
import pytest | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def app(): | ||
app = flask.Flask(__name__) | ||
app.config.update( | ||
{ | ||
"VERSION": "version", | ||
"DEFAULT_LANGUAGE": "en", | ||
} | ||
) | ||
ctx = app.app_context() | ||
ctx.push() | ||
yield app | ||
ctx.pop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from unittest.mock import patch | ||
|
||
from cp.output.formatter.cp_ninjs_formatter import CPNINJSFormatter | ||
|
||
|
||
@patch("superdesk.get_resource_service") | ||
def test_subject_relevance(mock): | ||
item = { | ||
"type": "text", | ||
"subject": [ | ||
{ | ||
"name": "Society", | ||
"qcode": "eef4a135-e188-4d1f-93f1-cf7af1f594a6", | ||
"source": "Semaphore", | ||
"altids": {"source_name": "source_id"}, | ||
"scheme": "subject", | ||
"original_source": "original_source_value", | ||
"relevance": 54, | ||
"creator": "Machine", | ||
}, | ||
], | ||
} | ||
formatter = CPNINJSFormatter() | ||
ninjs = formatter._transform_to_ninjs(item, {}) | ||
assert ninjs["subject"][0]["relevance"] == 54 | ||
assert ninjs["subject"][0]["creator"] == "Machine" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters