Пример #1
0
    def test_sector_repr(self):
        sector = Sector(12345)
        assert str(sector) == '<Sector (12345, Vocabulary: Unspecified)>'

        sector = Sector(151, vocabulary=2)
        sector_repr = '<Sector (Government and civil society, general ' + \
                      '(151), Vocabulary: OECD DAC CRS Purpose Codes ' + \
                      '(3 digit))>'
        assert str(sector) == sector_repr

        sector = Sector('ABCD', vocabulary=3)
        sector_repr = '<Sector (ABCD, Vocabulary: Classification of the ' + \
                      'Functions of Government (UN))>'
        assert str(sector) == sector_repr
Пример #2
0
 def test_activities_filter_by_sector_in(self):
     sector = Sector('151', vocabulary='2')
     acts = self.fixture_org_acts.where(sector__in=sector).all()
     assert len(acts) == 1
Пример #3
0
 def test_activities_filter_by_sector(self):
     sector = Sector('15163', vocabulary='DAC')
     acts = self.fixture_org_acts.where(sector=sector).all()
     assert len(acts) == 1
     assert acts[0].iati_identifier == 'GB-COH-01234567-1'
Пример #4
0
 def test_activity_sector(self):
     sector = Sector('73010', vocabulary='1')
     assert self.activity.sector[0] == sector
Пример #5
0
 def test_sector_from_bad_codelist_item(self):
     codelist = Codelist('Vocabulary', '1.05')
     codelist_item = codelist.get('DAC')
     with pytest.raises(InvalidSectorCodeError):
         Sector(codelist_item)
Пример #6
0
 def test_sector_from_dac_3_codelist_item(self):
     codelist = Codelist('SectorCategory', '2.03')
     codelist_item = codelist.get('151')
     sector = Sector(codelist_item)
     assert sector.code.code == '151'
Пример #7
0
 def test_sector_from_dac_5_codelist_item(self):
     codelist = Codelist('Sector', '2.03')
     codelist_item = codelist.get('73010')
     sector = Sector(codelist_item)
     assert sector.code.code == '73010'
Пример #8
0
 def test_sector_unknown_code(self):
     with pytest.raises(UnknownSectorCodeError):
         Sector(12345, vocabulary=1)
Пример #9
0
 def test_sector_unknown_vocab(self):
     with pytest.raises(UnknownSectorVocabError):
         Sector(12345, vocabulary=10)
Пример #10
0
 def test_sector_percentage(self):
     sector = Sector(12345, percentage=100)
     assert isinstance(sector.percentage, float)
     assert sector.percentage == 100.0