def test_throws_on_missing_site_id(self): with self.assertRaises( exceptions.MissingRequiredFieldXmlParseException): dtos.TaxonomyTerm(id='id', name='name', organization_id='organization_id', description='description')
def test_throws_on_missing_name(self): with self.assertRaises( exceptions.MissingRequiredFieldXmlParseException): dtos.TaxonomyTerm(taxonomy_id='taxonomy_id')
def test_can_create(self): taxonomy_term = dtos.TaxonomyTerm(taxonomy_id='taxonomy_id', name='name') self.assertEqual(taxonomy_term.taxonomy_id, 'taxonomy_id') self.assertEqual(taxonomy_term.name, 'name')
def parse_airs_taxonomy_term(code_str): taxonomy_id = 'airs' yield dtos.TaxonomyTerm(taxonomy_id=taxonomy_id, name=code_str)
def parse_bc211_taxonomy_term(code_str): bc211_json_re = r"(\w+)\:\'([^\']+)\'" groups = re.findall(bc211_json_re, code_str) for (taxonomy_id, name) in groups: full_taxonomy_id = 'bc211-{}'.format(taxonomy_id) yield dtos.TaxonomyTerm(taxonomy_id=full_taxonomy_id, name=name)