Skip to content

Commit

Permalink
Merge pull request #84 from marwoodandrew/fix-priority
Browse files Browse the repository at this point in the history
fix(aap-priority) missing from aap nitf
  • Loading branch information
akintolga authored Aug 14, 2016
2 parents cb5a2e2 + 741e10b commit d502844
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions server/aap/publish/formatters/aap_nitf_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions server/aap/publish/formatters/aap_nitf_formatter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,31 @@ def test_formatter(self):
article = {
'headline': 'test headline',
'body_html': '<p>test body</p>',
'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]
nitf_xml = etree.fromstring(doc)
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 = {
Expand Down

0 comments on commit d502844

Please sign in to comment.