Exemple #1
0
 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)
Exemple #2
0
 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)
Exemple #3
0
    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)
Exemple #4
0
    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)
Exemple #5
0
 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)
Exemple #6
0
    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)
Exemple #7
0
 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()
Exemple #8
0
 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)
Exemple #9
0
 def setUp(self):
     super().setUp()
     self.activities = list(
         parse.document_from_file(
             fixture_filename("2.01-example-annotated.xml")))
     self.act = self.activities[0]
Exemple #10
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)
Exemple #11
0
 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)
Exemple #12
0
def parse_fixture(fix_name, encoding='utf-8'):
    return ET.parse(fixture_filename(fix_name))
Exemple #13
0
 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)
Exemple #14
0
 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)
Exemple #15
0
 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)
Exemple #16
0
 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)
Exemple #17
0
def fixture(fix_name, encoding='utf-8'):
    return codecs.open(fixture_filename(fix_name), encoding=encoding).read()
Exemple #18
0
 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)
Exemple #19
0
 def test_raw_xml(self):
     norm_xml = ET.tostring(ET.parse(fixture_filename("default_currency.xml")))
     self.assertEquals(norm_xml, self.act.raw_xml)
Exemple #20
0
 def test_save_repeated_participation(self):
     activities = parse.document_from_file(
         fixture_filename("repeated_participation.xml"))
     db.session.add_all(activities)
     db.session.commit()
Exemple #21
0
 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)
Exemple #22
0
 def test_big_values(self):
     activities = parse.document_from_file(
         fixture_filename("big_value.xml"))
     db.session.add_all(activities)
     db.session.commit()
Exemple #23
0
 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)
Exemple #24
0
def fixture(fix_name, encoding='utf-8'):
    return open(fixture_filename(fix_name), encoding=encoding).read()
Exemple #25
0
 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) 
Exemple #26
0
 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)
Exemple #27
0
 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)
Exemple #28
0
 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))
Exemple #29
0
 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)
Exemple #30
0
 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)
Exemple #31
0
 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)
Exemple #32
0
 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) 
Exemple #33
0
 def setUp(self):
     super(TestParse2xxActivity, self).setUp()
     self.activities = list(parse.document(fixture_filename("2.01-example-annotated.xml")))
     self.act = self.activities[0]
Exemple #34
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)
Exemple #35
0
 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) 
Exemple #36
0
 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)
Exemple #37
0
 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) 
Exemple #38
0
 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)
Exemple #39
0
 def test_save_parsed_201(self):
     activities = parse.document(fixture_filename("2.01-example-annotated.xml"))
     db.session.add_all(activities)
     db.session.commit()
Exemple #40
0
 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)
Exemple #41
0
 def test_save_repeated_participation(self):
     activities = parse.document(fixture_filename("repeated_participation.xml"))
     db.session.add_all(activities)
     db.session.commit()
Exemple #42
0
 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()
Exemple #43
0
 def test_different_roles(self):
     activities = parse.document(fixture_filename("same_orgs_different_roles.xml"))
     db.session.add_all(activities)
     db.session.commit()
Exemple #44
0
 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()
Exemple #45
0
 def test_big_values(self):
     activities = parse.document(fixture_filename("big_value.xml"))
     db.session.add_all(activities)
     db.session.commit()
Exemple #46
0
 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)
Exemple #47
0
 def setUp(self):
     super(TestParse2xxActivity, self).setUp()
     self.activities = list(parse.document(fixture_filename("2.01-example-annotated.xml")))
     self.act = self.activities[0]