def test_issue12_saopaulo(): cable = cable_by_id('08SAOPAULO335') eq_(u'VZCZCXRO3989', cable.transmission_id) eq_(u'08SAOPAULO335', cable.reference_id) eq_(u'08SAOPAULO335', cable.canonical_id) cable = cable_by_id('08SCTION02OF02SAOPAULO335') eq_(u'VZCZCXRO3727', cable.transmission_id) eq_('08SCTION02OF02SAOPAULO335', cable.reference_id) eq_(u'08SAOPAULO335', cable.canonical_id)
def test_issue12_manama(): cable = cable_by_id('08MANAMA492') eq_(u'VZCZCXRO5008', cable.transmission_id) eq_(u'08MANAMA492', cable.reference_id) eq_(u'08MANAMA492', cable.canonical_id) cable = cable_by_id('08ECTION01OF02MANAMA492') eq_(u'VZCZCXRO4772', cable.transmission_id) eq_(u'08ECTION01OF02MANAMA492', cable.reference_id) eq_(u'08MANAMA492', cable.canonical_id)
def test_issue(): cable = cable_by_id('00HARARE2297') ok_(cable) ok_(cable.is_partial, 'Expected is_partial == True') signers = tuple(cable.signed_by) eq_(1, len(signers)) eq_(u'MCDONALD', signers[0])
def check(incorrect_id, correct_id): cable = cable_by_id(correct_id) ok_(cable is not None) eq_(incorrect_id, cable.reference_id) eq_(c14n.canonicalize_id(incorrect_id), cable.canonical_id, 'Unexpected canonical identifier for the incorrect id') eq_(c14n.canonicalize_id(correct_id), cable.canonical_id, 'Unexpected canonical identifier for the correct id')
def test_issue5(): # # Note: The issue lists # (B) Sao Paulo 215; # (C) 05 Sao Paulo 975 # # but the cable changed to: # REF: A) Sao Paulo 319 B) Sao Paulo 278 # # (2011-07-15) # cable = cable_by_id('06SAOPAULO348') assert cable refs = [ref.value for ref in cable.references if ref.is_cable()] assert u'06SAOPAULO319' in refs assert u'06SAOPAULO278' in refs eq_([u'PGOV', u'PHUM', u'KCRM', u'SOCI', u'SNAR', u'ASEC', u'BR'], cable.tags)
def test_parse_subject(): def check(expected, cable): eq_(expected, cable.subject) for ref_id, subject in _TEST_DATA: yield check, subject, cable_by_id(ref_id)
def check(cable_id, references): cable = cable_by_id(cable_id) assert cable eq_(references, [ref.value for ref in cable.references if ref.is_cable()])
def check(expected, cable_id, c14n): cable = cable_by_id(cable_id) if not isinstance(expected, tuple): expected = (expected,) eq_(expected, tuple(parse_signed_by(cable.content, c14n)))
def test_issue15(): def check(cable, expected): eq_(expected, cable.subject) for ref, subject in _TEST_DATA: yield check, cable_by_id(ref), subject
def test_nosubject(): def check(cable): eq_(u'', cable.subject) for ref_id in _CABLES_WO_SUBJECT: yield check, cable_by_id(ref_id)
def test_by_id(): def check(cable, expected): eq_(expected, cable.tags) for ref_id, expected in _TEST_DATA_BY_ID: yield check, cable_by_id(ref_id), expected
def test_issue25(): cable = cable_by_id('09NAIROBI1938') refs = [ref.value for ref in cable.references if ref.is_cable()] eq_([u'08STATE81854', u'09NAIROBI1830', u'09NAIROBI1859', u'09NAIROBI1831'], refs)
def check(cable_id, expected): if not isinstance(expected, tuple): expected = (expected, ) cable = cable_by_id(cable_id) ok_(cable, 'Cable "%s" not found' % cable_id) eq_(expected, tuple(cable.classified_by))
def test_media_urls(): def check(cable, media_urls): eq_(sorted(cable.media_uris), sorted(media_urls)) for cable_id, media_urls in _TEST_DATA: yield check, cable_by_id(cable_id), media_urls
def check(cable_id, expected): if not isinstance(expected, tuple): expected = (expected,) cable = cable_by_id(cable_id) ok_(cable, 'Cable "%s" not found' % cable_id) eq_(expected, tuple(cable.classified_by))
def check(expected, cable_id, c14n): cable = cable_by_id(cable_id) if not isinstance(expected, tuple): expected = (expected, ) eq_(expected, tuple(parse_signed_by(cable.content, c14n)))