Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Metagenomics
metagenedb
Commits
f4593166
Commit
f4593166
authored
Nov 04, 2019
by
Kenzo-Hugo Hillion
♻
Browse files
fix test for hierarchy
parent
8e08ff30
Pipeline
#17555
passed with stages
in 2 minutes and 14 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
backend/metagenedb/apps/catalog/models/test_taxonomy.py
View file @
f4593166
from
unit
test
import
TestCase
from
rest_framework.
test
import
API
TestCase
from
.taxonom
y
import
Taxonomy
from
metagenedb.apps.catalog.factor
y
import
Taxonomy
Factory
class
TestBuildHierarchy
(
TestCase
):
class
TestBuildHierarchy
(
API
TestCase
):
@
classmethod
def
setUpClass
(
cls
):
def
setUp
(
self
):
"""
Build some test data for different tests
"""
cls
.
root
=
Taxonomy
(
self
.
root
=
Taxonomy
Factory
.
create
(
tax_id
=
"1"
,
name
=
"root"
,
rank
=
"no_rank"
,
)
cls
.
kingdom
=
Taxonomy
(
self
.
kingdom
=
Taxonomy
Factory
(
tax_id
=
"2"
,
name
=
"KINGDOM"
,
rank
=
"kingdom"
,
parent
=
cls
.
root
parent
=
self
.
root
)
cls
.
phylum
=
Taxonomy
(
self
.
phylum
=
Taxonomy
Factory
(
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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment