def test_activity_status(self): activities = [ a for a in parse.document_from_file( fixture_filename("default_currency.xml")) ] self.assertEquals(cl.ActivityStatus.implementation, activities[0].activity_status)
def test_related_activity(self): activities = [ a for a in parse.document_from_file(fixture_filename("CD.xml")) ] self.assertEquals(4, len(activities[0].related_activities)) self.assertEquals("GB-1-105838-101", activities[0].related_activities[0].ref)
def test_policy_markers(self): activities = [ a for a in parse.document(fixture_filename("CD.xml")) ] self.assertEquals(8, len(activities[1].policy_markers)) self.assertEquals(cl.PolicyMarker.gender_equality, activities[1].policy_markers[0].code) self.assertEquals(cl.PolicyMarker.aid_to_environment, activities[1].policy_markers[1].code) self.assertEquals(cl.PolicyMarker.participatory_developmentgood_governance, activities[1].policy_markers[2].code) self.assertEquals(cl.PolicyMarker.trade_development, activities[1].policy_markers[3].code)
def test_dates(self): activities = list(parse.document_from_file(fixture_filename("CD.xml"))) self.assertEquals(datetime.date(2004, 1, 1), activities[0].start_planned) self.assertEquals(datetime.date(2004, 1, 1), activities[0].start_actual) self.assertEquals(datetime.date(2010, 12, 31), activities[0].end_planned) self.assertEquals(datetime.date(2010, 12, 31), activities[0].end_actual)
def test_policy_markers_significance(self): activities = [ a for a in parse.document_from_file(fixture_filename("CD.xml")) ] self.assertEquals(8, len(activities[1].policy_markers)) self.assertEquals(cl.PolicySignificance.significant_objective, activities[1].policy_markers[0].significance) self.assertEquals(cl.PolicySignificance.not_targeted, activities[1].policy_markers[1].significance) self.assertEquals(cl.PolicySignificance.significant_objective, activities[1].policy_markers[2].significance) self.assertEquals(cl.PolicySignificance.not_targeted, activities[1].policy_markers[3].significance)
def test_save_parsed_201(self): activities = parse.document_from_file( fixture_filename("2.01-example-annotated.xml")) db.session.add_all(activities) db.session.commit()
def test_raw_xml(self): norm_xml = ET.tostring(ET.parse(fixture_filename("2.01-example-annotated.xml")).find('iati-activity'), encoding=unicode).strip(u'\n ') self.assertEquals(norm_xml, self.act.raw_xml)
def setUp(self): super().setUp() self.activities = list( parse.document_from_file( fixture_filename("2.01-example-annotated.xml"))) self.act = self.activities[0]
def test_raw_xml(self): norm_xml = ET.tostring( ET.parse(fixture_filename("default_currency.xml"))).decode("utf-8") self.assertEquals(norm_xml, self.act.raw_xml)
def test_default_finance_type(self): activities = [ a for a in parse.document(fixture_filename("CD.xml")) ] self.assertEquals(cl.FinanceType.aid_grant_excluding_debt_reorganisation, activities[1].default_finance_type)
def parse_fixture(fix_name, encoding='utf-8'): return ET.parse(fixture_filename(fix_name))
def test_collaboration_type(self): activities = [ a for a in parse.document(fixture_filename("CD.xml")) ] self.assertEquals(cl.CollaborationType.bilateral, activities[1].collaboration_type)
def test_related_activity(self): activities = [ a for a in parse.document(fixture_filename("CD.xml")) ] self.assertEquals(4, len(activities[0].related_activities)) self.assertEquals("GB-1-105838-101", activities[0].related_activities[0].ref)
def test_activity_status(self): activities = [ a for a in parse.document(fixture_filename("default_currency.xml")) ] self.assertEquals(cl.ActivityStatus.implementation, activities[0].activity_status)
def fixture(fix_name, encoding='utf-8'): return codecs.open(fixture_filename(fix_name), encoding=encoding).read()
def test_no_start_actual(self): activities = parse.document(fixture_filename("missing_dates.xml")) act = {a.iati_identifier:a for a in activities} self.assertEquals(None, act[u"GB-CHC-272465-680"].start_actual)
def test_raw_xml(self): norm_xml = ET.tostring(ET.parse(fixture_filename("default_currency.xml"))) self.assertEquals(norm_xml, self.act.raw_xml)
def test_save_repeated_participation(self): activities = parse.document_from_file( fixture_filename("repeated_participation.xml")) db.session.add_all(activities) db.session.commit()
def test_default_flow_type(self): activities = [ a for a in parse.document(fixture_filename("CD.xml")) ] self.assertEquals(cl.FlowType.oda, activities[1].default_flow_type)
def test_big_values(self): activities = parse.document_from_file( fixture_filename("big_value.xml")) db.session.add_all(activities) db.session.commit()
def test_default_aid_type(self): activities = [ a for a in parse.document(fixture_filename("CD.xml")) ] self.assertEquals(cl.AidType.projecttype_interventions, activities[1].default_aid_type)
def fixture(fix_name, encoding='utf-8'): return open(fixture_filename(fix_name), encoding=encoding).read()
def test_default_hierarchy(self): activities = [ a for a in parse.document(fixture_filename("default_currency.xml")) ] self.assertEquals(cl.RelatedActivityType.parent, activities[0].hierarchy)
def test_raw_xml(self): norm_xml = ET.tostring(ET.parse( fixture_filename("2.01-example-annotated.xml")).find( 'iati-activity'), encoding='utf-8').decode("utf-8") self.assertEquals(norm_xml, self.act.raw_xml)
def test_default_finance_type(self): activities = [ a for a in parse.document_from_file(fixture_filename("CD.xml")) ] self.assertEquals(cl.FinanceType.standard_grant, activities[1].default_finance_type)
def test_sector_percentage_count(self): act = next( parse.document_from_file( fixture_filename("complex_example_dfid.xml"))) self.assertEquals(5, len(act.sector_percentages))
def test_default_aid_type(self): activities = [ a for a in parse.document_from_file(fixture_filename("CD.xml")) ] self.assertEquals(cl.AidType.projecttype_interventions, activities[1].default_aid_type)
def test_no_start_actual(self): activities = parse.document_from_file( fixture_filename("missing_dates.xml")) act = {a.iati_identifier: a for a in activities} self.assertEquals(None, act[u"GB-CHC-272465-680"].start_actual)
def test_default_hierarchy(self): activities = [ a for a in parse.document_from_file( fixture_filename("default_currency.xml")) ] self.assertEquals(1, activities[0].hierarchy)
def test_default_tied_status(self): activities = [ a for a in parse.document(fixture_filename("CD.xml")) ] self.assertEquals(cl.TiedStatus.untied, activities[1].default_tied_status)
def setUp(self): super(TestParse2xxActivity, self).setUp() self.activities = list(parse.document(fixture_filename("2.01-example-annotated.xml"))) self.act = self.activities[0]
def test_collaboration_type(self): activities = [ a for a in parse.document_from_file(fixture_filename("CD.xml")) ] self.assertEquals(cl.CollaborationType.bilateral, activities[1].collaboration_type)
def test_default_flow_type(self): activities = [ a for a in parse.document_from_file(fixture_filename("CD.xml")) ] self.assertEquals(cl.FlowType.oda, activities[1].default_flow_type)
def test_default_language(self): activities = [ a for a in parse.document(fixture_filename("default_currency.xml")) ] self.assertEquals(cl.Language.english, activities[0].default_language)
def test_default_tied_status(self): activities = [ a for a in parse.document_from_file(fixture_filename("CD.xml")) ] self.assertEquals(cl.TiedStatus.untied, activities[1].default_tied_status)
def test_save_parsed_201(self): activities = parse.document(fixture_filename("2.01-example-annotated.xml")) db.session.add_all(activities) db.session.commit()
def test_default_language(self): activities = [ a for a in parse.document_from_file( fixture_filename("default_currency.xml")) ] self.assertEquals(cl.Language.english, activities[0].default_language)
def test_save_repeated_participation(self): activities = parse.document(fixture_filename("repeated_participation.xml")) db.session.add_all(activities) db.session.commit()
def test_save_complex_example(self): acts = parse.document_from_file( fixture_filename("complex_example_dfid.xml")) db.session.add_all(acts) db.session.commit()
def test_different_roles(self): activities = parse.document(fixture_filename("same_orgs_different_roles.xml")) db.session.add_all(activities) db.session.commit()
def test_different_roles(self): activities = parse.document_from_file( fixture_filename("same_orgs_different_roles.xml")) db.session.add_all(activities) db.session.commit()
def test_big_values(self): activities = parse.document(fixture_filename("big_value.xml")) db.session.add_all(activities) db.session.commit()
def test_dates(self): activities = list(parse.document(fixture_filename("CD.xml"))) self.assertEquals(datetime.date(2004, 1, 1), activities[0].start_planned) self.assertEquals(datetime.date(2004, 1, 1), activities[0].start_actual) self.assertEquals(datetime.date(2010, 12, 31), activities[0].end_planned) self.assertEquals(datetime.date(2010, 12, 31), activities[0].end_actual)