Skip to content
Snippets Groups Projects
Commit f4593166 authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion :recycle:
Browse files

fix test for hierarchy

parent 8e08ff30
No related branches found
No related tags found
2 merge requests!59Prod,!16Add endpoint to generate hierarchy of taxonomy from the backend
Pipeline #17555 passed with stages
in 2 minutes and 14 seconds
from unittest import TestCase
from rest_framework.test import APITestCase
from .taxonomy import Taxonomy
from metagenedb.apps.catalog.factory import TaxonomyFactory
class TestBuildHierarchy(TestCase):
class TestBuildHierarchy(APITestCase):
@classmethod
def setUpClass(cls):
def setUp(self):
"""
Build some test data for different tests
"""
cls.root = Taxonomy(
self.root = TaxonomyFactory.create(
tax_id="1",
name="root",
rank="no_rank",
)
cls.kingdom = Taxonomy(
self.kingdom = TaxonomyFactory(
tax_id="2",
name="KINGDOM",
rank="kingdom",
parent=cls.root
parent=self.root
)
cls.phylum = Taxonomy(
self.phylum = TaxonomyFactory(
tax_id="3",
name="PHYLUM",
rank="phylum",
parent=cls.kingdom
parent=self.kingdom
)
def test_build_hierarchy(self):
expected_dict = {
'tax_id': '3',
'phylum': '3',
'kingdom': '2'
'phylum': self.phylum,
'kingdom': self.kingdom
}
self.assertNotEqual(getattr(self.phylum, 'kingdom', None), self.kingdom)
test_dict = self.phylum.build_parental_hierarchy()
self.assertDictEqual(test_dict, expected_dict)
self.assertEqual(getattr(self.phylum, 'kingdom', None), self.kingdom)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment