diff --git a/server/aap/publish/formatters/aap_nitf_formatter.py b/server/aap/publish/formatters/aap_nitf_formatter.py index 641bc53ad..db2a7522f 100644 --- a/server/aap/publish/formatters/aap_nitf_formatter.py +++ b/server/aap/publish/formatters/aap_nitf_formatter.py @@ -69,6 +69,10 @@ def _append_meta(self, article, head, destination, pub_seq_num): if SIGN_OFF in article: SubElement(head, 'meta', {'name': 'aap-signoff', 'content': article.get(SIGN_OFF, '')}) + def _append_meta_priority(self, article, head): + if 'priority' in article: + SubElement(head, 'meta', {'name': 'aap-priority', 'content': str(article['priority'])}) + def map_html_to_xml(self, element, html): """ Map the html text tags to xml diff --git a/server/aap/publish/formatters/aap_nitf_formatter_test.py b/server/aap/publish/formatters/aap_nitf_formatter_test.py index 4063389d2..d9e57ee0c 100644 --- a/server/aap/publish/formatters/aap_nitf_formatter_test.py +++ b/server/aap/publish/formatters/aap_nitf_formatter_test.py @@ -48,10 +48,16 @@ def test_formatter(self): article = { 'headline': 'test headline', 'body_html': '
test body
', + 'slugline': 'keyword', + 'anpa_take_key': 'take-key', + 'original_source': 'EMAIL', 'type': 'text', - 'priority': '1', + 'priority': '9', + 'source': 'SUP', '_id': 'urn:localhost.abc', - 'urgency': 2 + 'urgency': 2, + 'place': [{'qcode': 'FED'}], + 'sign_off': 'me' } seq, doc = self.formatter.format(article, {'name': 'Test Subscriber'})[0] @@ -59,6 +65,14 @@ def test_formatter(self): self.assertEqual(nitf_xml.find('head/title').text, article['headline']) self.assertEqual(nitf_xml.find('body/body.content/p').text, 'test body') self.assertEqual(nitf_xml.find('head/docdata/urgency').get('ed-urg'), '2') + self.assertEqual(nitf_xml.find('head/meta[@name="aap-priority"]').get('content'), '9') + self.assertEqual(nitf_xml.find('head/meta[@name="anpa-sequence"]').get('content'), str(seq)) + self.assertEqual(nitf_xml.find('head/meta[@name="anpa-keyword"]').get('content'), 'keyword') + self.assertEqual(nitf_xml.find('head/meta[@name="anpa-takekey"]').get('content'), 'take-key') + self.assertEqual(nitf_xml.find('head/meta[@name="aap-source"]').get('content'), 'SUP') + self.assertEqual(nitf_xml.find('head/meta[@name="aap-original-source"]').get('content'), 'EMAIL') + self.assertEqual(nitf_xml.find('head/meta[@name="aap-place"]').get('content'), 'FED') + self.assertEqual(nitf_xml.find('head/meta[@name="aap-signoff"]').get('content'), 'me') def test_company_codes(self): article = {