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
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
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'
def test_activity_sector(self): sector = Sector('73010', vocabulary='1') assert self.activity.sector[0] == sector
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)
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'
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'
def test_sector_unknown_code(self): with pytest.raises(UnknownSectorCodeError): Sector(12345, vocabulary=1)
def test_sector_unknown_vocab(self): with pytest.raises(UnknownSectorVocabError): Sector(12345, vocabulary=10)
def test_sector_percentage(self): sector = Sector(12345, percentage=100) assert isinstance(sector.percentage, float) assert sector.percentage == 100.0