def test_tree_freshness__fresh(self): create_nomenclature_tree() resp = self.anonymous_client.get(reverse("healthcheck:tree_freshness")) self.assertEqual(resp.content, b"OK") self.assertEqual(resp.status_code, 200)
def test_linkify_commodity_hs_codes(self): tree = create_nomenclature_tree("UK") country = mixer.blend(Country, country_code="XX") commodity_010101 = mixer.blend( Commodity, commodity_code="0101010000", goods_nomenclature_sid="010101", nomenclature_tree=tree, ) ( commodity_010101_detail_url, commodity_010101_hierarchy_url, ) = self.get_object_urls( "commodity", commodity_010101, country, ) commodity_010101_link_element = self.get_link_element( "0101.01", commodity_010101_detail_url, commodity_010101_hierarchy_url, ) result = self.render_linkify_hs_codes( "Subheading 0101.01", country.country_code, ) self.assertEqual(result, f"Subheading {commodity_010101_link_element}") result = self.render_linkify_hs_codes( "subheading 0101.01", country.country_code, ) self.assertEqual(result, f"subheading {commodity_010101_link_element}")
def setUp(self): self.tree = create_nomenclature_tree("UK") self.section = mixer.blend(Section, section_id=1, nomenclature_tree=self.tree) self.chapter = mixer.blend( Chapter, chapter_code="0100000000", section=self.section, nomenclature_tree=self.tree, ) self.heading = mixer.blend( Heading, heading_code="0101000000", chapter=self.chapter, nomenclature_tree=self.tree, ) self.subheading = mixer.blend( SubHeading, commodity_code="0101210000", heading=self.heading, nomenclature_tree=self.tree, ) self.commodity = mixer.blend( Commodity, commodity_code="0101210000", parent_subheading=self.subheading, goods_nomenclature_sid=12345, nomenclature_tree=self.tree, ) self.commodity.tts_json = json.dumps(get_data(settings.COMMODITY_STRUCTURE)) self.commodity.save_cache()
def test_linkify_chapter_hs_codes(self): tree = create_nomenclature_tree("UK") country = mixer.blend(Country, country_code="XX") chapter_01 = mixer.blend( Chapter, chapter_code="0100000000", goods_nomenclature_sid="01", nomenclature_tree=tree, ) chapter_10 = mixer.blend( Chapter, chapter_code="1000000000", goods_nomenclature_sid="10", nomenclature_tree=tree, ) chapter_01_detail_url, chapter_01_hierarchy_url = self.get_object_urls( "chapter", chapter_01, country) chapter_01_link_element = self.get_link_element( "1", chapter_01_detail_url, chapter_01_hierarchy_url) result = self.render_linkify_hs_codes( "Chapter 1 more text", country.country_code, ) self.assertEqual( result, f"Chapter {chapter_01_link_element} more text", ) result = self.render_linkify_hs_codes( "chapter 1 more text", country.country_code, ) self.assertEqual( result, f"chapter {chapter_01_link_element} more text", ) chapter_10_detail_url, chapter_10_hierarchy_url = self.get_object_urls( "chapter", chapter_10, country) chapter_10_link_element = self.get_link_element( "10", chapter_10_detail_url, chapter_10_hierarchy_url) result = self.render_linkify_hs_codes( "Chapter 10", country.country_code, ) self.assertEqual( result, f"Chapter {chapter_10_link_element}", ) result = self.render_linkify_hs_codes( "chapter 10", country.country_code, ) self.assertEqual( result, f"chapter {chapter_10_link_element}", )
def new_tree(self): """Sometimes HierarchyBuilder is used without having to create new objects, so the tree is only created when it's actually needed""" if not self._new_tree: self.region = self.region or DEFAULT_REGION self._new_tree = create_nomenclature_tree(region=self.region) return self._new_tree
def setUp(self): self.tree = create_nomenclature_tree("UK") self.model_classes = [Chapter, Section, Heading, SubHeading, Commodity] self.mixer = Mixer() for model_class in self.model_classes: self.mixer.register(model_class, nomenclature_tree=self.tree)
def set_up_nomenclature(self): self.country = Country.objects.all().first() self.tree = create_nomenclature_tree("UK") self.section = mixer.blend( Section, nomenclature_tree=self.tree, ) self.chapter = mixer.blend( Chapter, nomenclature_tree=self.tree, section=self.section, chapter_code="0100000000", goods_nomenclature_sid="264127", description="Inanimate Carbon Rods", ) self.heading = mixer.blend( Heading, nomenclature_tree=self.tree, chapter=self.chapter, heading_code="0101000000", goods_nomenclature_sid="2", ) self.subheading = mixer.blend( SubHeading, nomenclature_tree=self.tree, heading=self.heading, commodity_code="010101000", goods_nomenclature_sid="2", ) self.commodity = mixer.blend( Commodity, nomenclature_tree=self.tree, parent_subheading=self.subheading, commodity_code="010101011", goods_nomenclature_sid="2", description="Self Sealing Stem-Bolts", ) self.reg_group = mixer.blend( RegulationGroup, nomenclature_trees=[self.tree], chapters=[self.chapter], headings=[self.heading], title="Just an average regulation group", ) self.reg_group_unlinked = mixer.blend( RegulationGroup, title="Just an empty regulation group", )
def setUp(self): self.tree = create_nomenclature_tree(region="UK") self.commodity = mixer.blend( Commodity, commodity_code=settings.TEST_COMMODITY_CODE, goods_nomenclature_sid=12345, nomenclature_tree=self.tree, ) self.commodity.tts_json = json.dumps(get_data(settings.COMMODITY_DATA)) self.commodity.save_cache()
def setUp(self): self.tree = create_nomenclature_tree("UK") self.section = mixer.blend( Section, section_id=1, roman_numeral="I", tts_json="[]", nomenclature_tree=self.tree, )
def setUp(self): self.tree = create_nomenclature_tree("UK") self.heading = mixer.blend(Heading, tts_json="{}", nomenclature_tree=self.tree) self.parent_subheadings = mixer.cycle(5).blend( SubHeading, heading=self.heading, nomenclature_tree=self.tree ) self.heading_commodities = mixer.cycle(5).blend( Commodity, heading=self.heading, nomenclature_tree=self.tree )
def test_tree_freshness__stale(self): tree = create_nomenclature_tree() old_date = (timezone.now() - TreeRefreshCheckView.MAX_DELTA - dt.timedelta(days=1)) tree.start_date = old_date tree.save() resp = self.anonymous_client.get(reverse("healthcheck:tree_freshness")) self.assertEqual(resp.content, b"Failed") self.assertEqual(resp.status_code, 503)
def setUp(self): """ To test fully test a commodity we need to load a parent subheading and its parent heading and save the relationships between the three model instances :return: """ self.tree = create_nomenclature_tree(region="UK") self.section = self.create_instance( Section, get_data(settings.SECTION_STRUCTURE)) self.chapter = self.create_instance( Chapter, get_data(settings.CHAPTER_STRUCTURE)) self.chapter.section_id = self.section.pk self.chapter.save() self.heading = self.create_instance( Heading, get_data(settings.HEADING_STRUCTURE)) self.heading.chapter_id = self.chapter.id self.heading.save() self.subheading = self.create_instance( SubHeading, get_data(settings.SUBHEADING_STRUCTURE)) self.subheading.heading_id = self.heading.id self.subheading.save() self.commodity = self.create_instance( Commodity, get_data(settings.COMMODITY_STRUCTURE)) self.commodity.parent_subheading_id = self.subheading.id self.commodity.goods_nomenclature_sid = 12345 self.commodity.save() self.mock_commodity_tts_json = patch.object( Commodity, "tts_json", new_callable=PropertyMock( return_value=json.dumps(get_data(settings.COMMODITY_DATA))), ) self.mock_commodity_tts_json.start() self.client = Client() self.url = reverse( "commodity-detail", kwargs={ "commodity_code": settings.TEST_COMMODITY_CODE, "country_code": settings.TEST_COUNTRY_CODE, "nomenclature_sid": 12345, }, )
def setUp(self): tree = create_nomenclature_tree("UK") commodity = mixer.blend( Commodity, commodity_code=settings.TEST_COMMODITY_CODE, tts_json=json.dumps(get_data(settings.COMMODITY_DATA)), nomenclature_tree=tree, ) self.import_measure = ImportMeasureJson( commodity, get_data(settings.IMPORTMEASUREJSON_DATA), settings.TEST_COMMODITY_CODE, settings.TEST_COMMODITY_DESCRIPTION, settings.TEST_COUNTRY_CODE, )
def setUp(self) -> None: self.tree = create_nomenclature_tree() self.new_tree = NomenclatureTree.objects.create( region="UK", start_date=timezone.now(), end_date=timezone.now() ) self.model_classes = [ Chapter, Heading, SubHeading, Commodity, ] self.m2m_map = { Chapter: "chapters", Heading: "headings", SubHeading: "subheadings", Commodity: "commodities", }
def test_linkify_heading_hs_codes(self): tree = create_nomenclature_tree("UK") country = mixer.blend(Country, country_code="XX") heading = mixer.blend( Heading, heading_code="0101000000", goods_nomenclature_sid="0101", nomenclature_tree=tree, ) heading_detail_url, heading_hierarchy_url = self.get_object_urls( "heading", heading, country) heading_link_element = self.get_link_element("0101", heading_detail_url, heading_hierarchy_url) result = self.render_linkify_hs_codes( "Heading 0101", country.country_code, ) self.assertEqual(result, f"Heading {heading_link_element}") result = self.render_linkify_hs_codes( "heading 0101", country.country_code, ) self.assertEqual(result, f"heading {heading_link_element}") heading_link_element = self.get_link_element("01.01", heading_detail_url, heading_hierarchy_url) result = self.render_linkify_hs_codes( "Heading 01.01", country.country_code, ) self.assertEqual(result, f"Heading {heading_link_element}") result = self.render_linkify_hs_codes( "heading 01.01", country.country_code, ) self.assertEqual(result, f"heading {heading_link_element}")
def test_get_object_from_hit(self): tree = create_nomenclature_tree("UK") chapter = mixer.blend( Chapter, chapter_code="0100000000", goods_nomenclature_sid="1234", nomenclature_tree=tree, ) hit = self._get_hit("chapter", "1234", "0100000000") found_chapter = helpers.get_object_from_hit(hit) self.assertEqual(chapter, found_chapter) heading = mixer.blend( Heading, heading_code="0101000000", goods_nomenclature_sid="1234", nomenclature_tree=tree, ) hit = self._get_hit("heading", "1234", "0101000000") found_heading = helpers.get_object_from_hit(hit) self.assertEqual(heading, found_heading) subheading = mixer.blend( SubHeading, commodity_code="0101010000", goods_nomenclature_sid="1234", nomenclature_tree=tree, ) hit = self._get_hit("subheading", "1234", "0101010000") found_subheading = helpers.get_object_from_hit(hit) self.assertEqual(subheading, found_subheading) commodity = mixer.blend( Commodity, commodity_code="0101010100", goods_nomenclature_sid="1234", nomenclature_tree=tree, ) hit = self._get_hit("commodity", "1234", "0101010100") found_commodity = helpers.get_object_from_hit(hit) self.assertEqual(commodity, found_commodity)
def setUp(self): """ To fully test a commodity we need to load a parent subheading and its parent heading and save the relationships between the three model instances :return: """ self.tree = create_nomenclature_tree(region="UK") self.section = create_instance( get_data(settings.SECTION_STRUCTURE, self.tree), "hierarchy", "Section") self.chapter = create_instance( get_data(settings.CHAPTER_STRUCTURE, self.tree), "hierarchy", "Chapter") self.chapter.section_id = self.chapter.pk self.chapter.save() self.heading = create_instance( get_data(settings.HEADING_STRUCTURE, self.tree), "hierarchy", "Heading") self.heading.chapter_id = self.chapter.id self.heading.save() self.subheading = create_instance( get_data(settings.SUBHEADING_STRUCTURE, self.tree), "hierarchy", "SubHeading", ) self.subheading.heading_id = self.heading.id self.subheading.save() self.commodity = create_instance( get_data(settings.COMMODITY_STRUCTURE, self.tree), "commodities", "Commodity", ) self.commodity.parent_subheading_id = self.subheading.id self.commodity.tts_json = json.dumps( get_data(settings.COMMODITY_DATA, self.tree)) self.commodity.save()
def handle(self, *args, **options): model_names = [ "Section", "Chapter", "Heading", "SubHeading", "Commodity" ] with transaction.atomic(): with transaction.atomic(): prev_tree = NomenclatureTree.get_active_tree( settings.PRIMARY_REGION) # creating new tree automatically activates it (at least within transaction) new_tree = create_nomenclature_tree(settings.PRIMARY_REGION) builder = HierarchyBuilder(new_tree=new_tree) builder.data_scanner(model_names) builder.process_orphaned_subheadings() builder.process_orphaned_commodities(options["skip_commodity"]) if not options["activate_new_tree"]: # switch back active tree to previous since we only want to properly activate # the new one after we reindex ElasticSearch results if prev_tree: prev_tree.end_date = None prev_tree.save() new_tree.end_date = timezone.now() new_tree.save() with transaction.atomic(): # we are not indexing EU documents in ElasticSearch (at least # yet) so we can # safely activate this tree builder = HierarchyBuilder(region=settings.SECONDARY_REGION) builder.data_scanner(model_names) builder.process_orphaned_subheadings() builder.process_orphaned_commodities(options["skip_commodity"])
def setUp(self): self.tree = create_nomenclature_tree("UK") self.heading = mixer.blend( Heading, heading_code=settings.TEST_HEADING_CODE, description=settings.TEST_HEADING_DESCRIPTION, nomenclature_tree=self.tree, ) self.subheading = mixer.blend( SubHeading, commodity_code="0101210000", description="Horses", heading=self.heading, nomenclature_tree=self.tree, ) self.commodity_data = get_data(settings.COMMODITY_DATA) self.commodity = mixer.blend( Commodity, commodity_code=settings.TEST_COMMODITY_CODE, tts_json=json.dumps(self.commodity_data), parent_subheading=self.subheading, nomenclature_tree=self.tree, )
def test_matches_spanning_multiple_models_matches_lowest(self): tree = create_nomenclature_tree("UK") country = mixer.blend(Country, country_code="XX") mixer.blend( Heading, heading_code="0101000000", goods_nomenclature_sid="0101", nomenclature_tree=tree, ) subheading_0101 = mixer.blend( SubHeading, commodity_code="0101000000", goods_nomenclature_sid="0101", nomenclature_tree=tree, ) mixer.blend( SubHeading, commodity_code="0101010000", goods_nomenclature_sid="010101", nomenclature_tree=tree, ) commodity_010101 = mixer.blend( Commodity, commodity_code="0101010000", goods_nomenclature_sid="010101", nomenclature_tree=tree, ) ( subheading_0101_detail_url, subheading_0101_hierarchy_url, ) = self.get_object_urls( "subheading", subheading_0101, country, ) subheading_0101_link_element = self.get_link_element( "0101", subheading_0101_detail_url, subheading_0101_hierarchy_url, ) ( commodity_010101_detail_url, commodity_010101_hierarchy_url, ) = self.get_object_urls( "commodity", commodity_010101, country, ) commodity_010101_link_element = self.get_link_element( "0101.01", commodity_010101_detail_url, commodity_010101_hierarchy_url, ) result = self.render_linkify_hs_codes( "Heading 0101", country.country_code, ) self.assertEqual(result, f"Heading {subheading_0101_link_element}") result = self.render_linkify_hs_codes( "Subheading 0101.01", country.country_code, ) self.assertEqual(result, f"Subheading {commodity_010101_link_element}")
def setUp(self): self.tree = create_nomenclature_tree(region="UK")
def setUp(self): self.tree = create_nomenclature_tree("UK") self.section = mixer.blend( Section, section_id=10, title=settings.TEST_SECTION_DESCRIPTION, roman_numeral="X", tts_json="{}", nomenclature_tree=self.tree, ) """create three chapters starting at 47 and attach to section 10""" self.chapters = mixer.cycle(3).blend( Chapter, tts_json="{}", section=self.section, chapter_code=(x for x in [4700000000, 4800000000, 4900000000]), goods_nomenclature_sid=(x for x in [4700000000, 4800000000, 4900000000]), nomenclature_tree=self.tree, ) """create 11 headings starting at 4901 and attached to chapter 49""" self.headings = mixer.cycle(11).blend( Heading, chapter=self.chapters[2], heading_code=( x for x in [ 4901000000, 4902000000, 4903000000, 4904000000, 4905000000, 4906000000, 4907000000, 4908000000, 4909000000, 4910000000, 4911000000, ] ), goods_nomenclature_sid=( x for x in [ 4901000000, 4902000000, 4903000000, 4904000000, 4905000000, 4906000000, 4907000000, 4908000000, 4909000000, 4910000000, 4911000000, ] ), nomenclature_tree=self.tree, ) """create 6 subheadings starting at 4901 attached to heading 4901""" self.parent_subheadings = mixer.cycle(6).blend( SubHeading, heading=self.headings[0], commodity_code=( x for x in [ 4901000000, 4902000000, 4905000000, 4907000000, 4908000000, 4911000000, ] ), goods_nomenclature_sid=( x for x in [ 4901000000, 4902000000, 4905000000, 4907000000, 4908000000, 4911000000, ] ), nomenclature_tree=self.tree, ) """create 2 subheadings attached to subheading 4911""" self.subheadings = mixer.cycle(2).blend( SubHeading, parent_subheading=self.parent_subheadings[5], commodity_code=(x for x in [4911100000, 4911910000]), goods_nomenclature_sid=(x for x in [4911100000, 4911910000]), nomenclature_tree=self.tree, ) """create 1 subheading attached to subheading 491191""" self.sub_subheadings = mixer.cycle(1).blend( SubHeading, parent_subheading=self.subheadings[1], commodity_code=4911910000, goods_nomenclature_sid=4911910000, nomenclature_tree=self.tree, ) """create 3 commodites attached to """ self.commodities = mixer.cycle(3).blend( Commodity, parent_subheading=self.sub_subheadings[0], commodity_code=(x for x in [4911910010, 4911910090, 4911990000]), goods_nomenclature_sid=(x for x in [4911910010, 4911910090, 4911990000]), description=(x for x in ["Paper", "Scissors", "Rock"]), nomenclature_tree=self.tree, ) self.client = Client()
def test_linkify_multiple_chapters_hs_codes(self): tree = create_nomenclature_tree("UK") country = mixer.blend(Country, country_code="XX") chapter_10 = mixer.blend( Chapter, chapter_code="1000000000", goods_nomenclature_sid="10", nomenclature_tree=tree, ) chapter_20 = mixer.blend( Chapter, chapter_code="2000000000", goods_nomenclature_sid="20", nomenclature_tree=tree, ) chapter_30 = mixer.blend( Chapter, chapter_code="3000000000", goods_nomenclature_sid="30", nomenclature_tree=tree, ) chapter_10_detail_url, chapter_10_hierarchy_url = self.get_object_urls( "chapter", chapter_10, country) chapter_10_link_element = self.get_link_element( "10", chapter_10_detail_url, chapter_10_hierarchy_url) chapter_20_detail_url, chapter_20_hierarchy_url = self.get_object_urls( "chapter", chapter_20, country) chapter_20_link_element = self.get_link_element( "20", chapter_20_detail_url, chapter_20_hierarchy_url) chapter_30_detail_url, chapter_30_hierarchy_url = self.get_object_urls( "chapter", chapter_30, country) chapter_30_link_element = self.get_link_element( "30", chapter_30_detail_url, chapter_30_hierarchy_url) result = self.render_linkify_hs_codes( "Chapters 10 and 20", country.country_code, ) self.assertEqual( result, f"Chapters {chapter_10_link_element} and {chapter_20_link_element}", ) result = self.render_linkify_hs_codes( "chapters 10 and 20", country.country_code, ) self.assertEqual( result, f"chapters {chapter_10_link_element} and {chapter_20_link_element}", ) result = self.render_linkify_hs_codes( "Chapters 10, 20 and 30", country.country_code, ) self.assertEqual( result, f"Chapters {chapter_10_link_element}, {chapter_20_link_element} and {chapter_30_link_element}", ) result = self.render_linkify_hs_codes( "chapters 10, 20 and 30", country.country_code, ) self.assertEqual( result, f"chapters {chapter_10_link_element}, {chapter_20_link_element} and {chapter_30_link_element}", )
def setUp(self): self.tree = create_nomenclature_tree("UK") self.chapter = mixer.blend(Chapter, tts_json="{}", nomenclature_tree=self.tree)
def test_linkify_multiple_subheadings_hs_codes(self): tree = create_nomenclature_tree("UK") country = mixer.blend(Country, country_code="XX") subheading_0101 = mixer.blend( SubHeading, commodity_code="0101000000", goods_nomenclature_sid="0101", nomenclature_tree=tree, ) subheading_0202 = mixer.blend( SubHeading, commodity_code="0202000000", goods_nomenclature_sid="0202", nomenclature_tree=tree, ) subheading_010101 = mixer.blend( SubHeading, commodity_code="0101010000", goods_nomenclature_sid="010101", nomenclature_tree=tree, ) ( subheading_0101_detail_url, subheading_0101_hierarchy_url, ) = self.get_object_urls( "subheading", subheading_0101, country, ) subheading_0101_link_element = self.get_link_element( "0101", subheading_0101_detail_url, subheading_0101_hierarchy_url, ) ( subheading_0202_detail_url, subheading_0202_hierarchy_url, ) = self.get_object_urls( "subheading", subheading_0202, country, ) subheading_0202_link_element = self.get_link_element( "02.02", subheading_0202_detail_url, subheading_0202_hierarchy_url, ) ( subheading_010101_detail_url, subheading_010101_hierarchy_url, ) = self.get_object_urls( "subheading", subheading_010101, country, ) subheading_010101_link_element = self.get_link_element( "0101.01", subheading_010101_detail_url, subheading_010101_hierarchy_url, ) result = self.render_linkify_hs_codes( "Subheadings 0101 and 02.02", country.country_code, ) self.assertEqual( result, f"Subheadings {subheading_0101_link_element} and {subheading_0202_link_element}", ) result = self.render_linkify_hs_codes( "subheadings 0101 and 02.02", country.country_code, ) self.assertEqual( result, f"subheadings {subheading_0101_link_element} and {subheading_0202_link_element}", ) result = self.render_linkify_hs_codes( "Subheadings 0101, 02.02 and 0101.01", country.country_code, ) self.assertEqual( result, f"Subheadings {subheading_0101_link_element}, {subheading_0202_link_element} " f"and {subheading_010101_link_element}", ) result = self.render_linkify_hs_codes( "subheadings 0101, 02.02 and 0101.01", country.country_code, ) self.assertEqual( result, f"subheadings {subheading_0101_link_element}, {subheading_0202_link_element} " f"and {subheading_010101_link_element}", )
def test_linkify_multiple_headings_hs_codes(self): tree = create_nomenclature_tree("UK") country = mixer.blend(Country, country_code="XX") heading_0101 = mixer.blend( Heading, heading_code="0101000000", goods_nomenclature_sid="0101", nomenclature_tree=tree, ) heading_0202 = mixer.blend( Heading, heading_code="0202000000", goods_nomenclature_sid="0202", nomenclature_tree=tree, ) heading_0303 = mixer.blend( Heading, heading_code="0303000000", goods_nomenclature_sid="0303", nomenclature_tree=tree, ) heading_0101_detail_url, heading_0101_hierarchy_url = self.get_object_urls( "heading", heading_0101, country) heading_0101_link_element = self.get_link_element( "0101", heading_0101_detail_url, heading_0101_hierarchy_url) heading_0202_detail_url, heading_0202_hierarchy_url = self.get_object_urls( "heading", heading_0202, country) heading_0202_link_element = self.get_link_element( "0202", heading_0202_detail_url, heading_0202_hierarchy_url) heading_0303_detail_url, heading_0303_hierarchy_url = self.get_object_urls( "heading", heading_0303, country) heading_0303_link_element = self.get_link_element( "0303", heading_0303_detail_url, heading_0303_hierarchy_url) result = self.render_linkify_hs_codes( "Headings 0101 and 0202", country.country_code, ) self.assertEqual( result, f"Headings {heading_0101_link_element} and {heading_0202_link_element}", ) result = self.render_linkify_hs_codes( "headings 0101 and 0202", country.country_code, ) self.assertEqual( result, f"headings {heading_0101_link_element} and {heading_0202_link_element}", ) result = self.render_linkify_hs_codes( "Headings 0101, 0202 and 0303", country.country_code, ) self.assertEqual( result, f"Headings {heading_0101_link_element}, {heading_0202_link_element} and {heading_0303_link_element}", ) result = self.render_linkify_hs_codes( "headings 0101, 0202 and 0303", country.country_code, ) self.assertEqual( result, f"headings {heading_0101_link_element}, {heading_0202_link_element} and {heading_0303_link_element}", )
def setUp(self): self.old_eu_tree = create_nomenclature_tree("EU") self.eu_tree = create_nomenclature_tree("EU") self.old_uk_tree = create_nomenclature_tree("UK") self.uk_tree = create_nomenclature_tree("UK")