@@ -331,7 +331,7 @@ def test_get_root(self) -> None:
331331 # These are the root tags, in alphabetical order:
332332 {"value" : "Archaea" , "child_count" : 3 , "descendant_count" : 3 , ** common_fields },
333333 {"value" : "Bacteria" , "child_count" : 2 , "descendant_count" : 2 , ** common_fields },
334- {"value" : "Eukaryota" , "child_count" : 5 , "descendant_count" : 13 , ** common_fields },
334+ {"value" : "Eukaryota" , "child_count" : 5 , "descendant_count" : 5 , ** common_fields },
335335 ]
336336
337337 def test_get_child_tags_one_level (self ) -> None :
@@ -345,7 +345,7 @@ def test_get_child_tags_one_level(self) -> None:
345345 del r ["_id" ] # Remove the internal database IDs; they aren't interesting here and a other tests check them
346346 assert result == [
347347 # These are the Eukaryota tags, in alphabetical order:
348- {"value" : "Animalia" , "child_count" : 7 , "descendant_count" : 8 , ** common_fields },
348+ {"value" : "Animalia" , "child_count" : 7 , "descendant_count" : 7 , ** common_fields },
349349 {"value" : "Fungi" , "child_count" : 0 , "descendant_count" : 0 , ** common_fields },
350350 {"value" : "Monera" , "child_count" : 0 , "descendant_count" : 0 , ** common_fields },
351351 {"value" : "Plantae" , "child_count" : 0 , "descendant_count" : 0 , ** common_fields },
@@ -441,8 +441,8 @@ def test_get_all(self) -> None:
441441 "Bacteria (None) (children: 2)" ,
442442 " Archaebacteria (Bacteria) (children: 0)" ,
443443 " Eubacteria (Bacteria) (children: 0)" ,
444- "Eukaryota (None) (children: 5 + 8 )" ,
445- " Animalia (Eukaryota) (children: 7 + 1 )" ,
444+ "Eukaryota (None) (children: 5)" ,
445+ " Animalia (Eukaryota) (children: 7)" ,
446446 " Arthropoda (Animalia) (children: 0)" ,
447447 " Chordata (Animalia) (children: 1)" ,
448448 " Mammalia (Chordata) (children: 0)" ,
@@ -478,7 +478,7 @@ def test_search_2(self) -> None:
478478 """
479479 result = pretty_format_tags (self .taxonomy .get_filtered_tags (search_term = "chordata" ))
480480 assert result == [
481- "Eukaryota (None) (children: 1 + 1 )" , # Has one child that matches, plus one additional matching descendant
481+ "Eukaryota (None) (children: 1)" , # Has one child that matches
482482 " Animalia (Eukaryota) (children: 1)" ,
483483 " Chordata (Animalia) (children: 0)" , # this is the matching tag.
484484 ]
@@ -492,8 +492,8 @@ def test_search_3(self) -> None:
492492 assert result == [
493493 "Archaea (None) (children: 1)" ,
494494 " Proteoarchaeota (Archaea) (children: 0)" ,
495- "Eukaryota (None) (children: 2 + 2 )" , # 2 direct matching children, 2 additional matching descendants
496- " Animalia (Eukaryota) (children: 2)" ,
495+ "Eukaryota (None) (children: 2)" , # 2 direct matching children
496+ " Animalia (Eukaryota) (children: 2)" , # also 2 matching children
497497 " Arthropoda (Animalia) (children: 0)" , # match
498498 " Gastrotrich (Animalia) (children: 0)" , # match
499499 " Protista (Eukaryota) (children: 0)" , # match
@@ -575,7 +575,7 @@ def test_tree_sort(self) -> None:
575575 taxonomy = self .create_sort_test_taxonomy ()
576576 result = pretty_format_tags (taxonomy .get_filtered_tags ())
577577 assert result == [
578- "1 (None) (children: 4 + 1 )" ,
578+ "1 (None) (children: 4)" ,
579579 " 1 A (1) (children: 0)" ,
580580 " 11 (1) (children: 0)" ,
581581 " 11111 (1) (children: 1)" ,
@@ -595,43 +595,6 @@ def test_tree_sort(self) -> None:
595595 " azure (ALPHABET) (children: 0)" ,
596596 ]
597597
598- def test_descendant_counts (self ) -> None :
599- """
600- Test getting the descendant count on a taxonomy known to cause aggregation
601- bugs unless the aggregations are correctly specified with distinct=True
602-
603- https://docs.djangoproject.com/en/5.0/topics/db/aggregation/#combining-multiple-aggregations
604- """
605- taxonomy = api .create_taxonomy ("ESDC Subset" )
606- api .add_tag_to_taxonomy (taxonomy , "Interests" ) # root tag
607- api .add_tag_to_taxonomy (taxonomy , "Holland Codes" , parent_tag_value = "Interests" ) # child tag
608- # Create the grandchild tag:
609- g_tag = api .add_tag_to_taxonomy (taxonomy , "Interests - Holland Codes" , parent_tag_value = "Holland Codes" )
610- # Create the 6 great-grandchild tags:
611- api .add_tag_to_taxonomy (taxonomy , "Artistic" , parent_tag_value = g_tag .value )
612- api .add_tag_to_taxonomy (taxonomy , "Conventional" , parent_tag_value = g_tag .value )
613- api .add_tag_to_taxonomy (taxonomy , "Enterprising" , parent_tag_value = g_tag .value )
614- api .add_tag_to_taxonomy (taxonomy , "Investigative" , parent_tag_value = g_tag .value )
615- api .add_tag_to_taxonomy (taxonomy , "Realistic" , parent_tag_value = g_tag .value )
616- api .add_tag_to_taxonomy (taxonomy , "Social" , parent_tag_value = g_tag .value )
617-
618- result = pretty_format_tags (taxonomy .get_filtered_tags (depth = 1 , include_counts = True ))
619- assert result == [
620- "Interests (None) (used: 0, children: 1 + 7)" , # 1 child + (1 grandchild and 6 great grandchild tags)
621- ]
622- result2 = pretty_format_tags (taxonomy .get_filtered_tags (depth = None , include_counts = True ))
623- assert result2 == [
624- "Interests (None) (used: 0, children: 1 + 7)" ,
625- " Holland Codes (Interests) (used: 0, children: 1 + 6)" ,
626- " Interests - Holland Codes (Holland Codes) (used: 0, children: 6)" ,
627- " Artistic (Interests - Holland Codes) (used: 0, children: 0)" ,
628- " Conventional (Interests - Holland Codes) (used: 0, children: 0)" ,
629- " Enterprising (Interests - Holland Codes) (used: 0, children: 0)" ,
630- " Investigative (Interests - Holland Codes) (used: 0, children: 0)" ,
631- " Realistic (Interests - Holland Codes) (used: 0, children: 0)" ,
632- " Social (Interests - Holland Codes) (used: 0, children: 0)" ,
633- ]
634-
635598
636599class TestFilteredTagsFreeTextTaxonomy (TestCase ):
637600 """
0 commit comments