1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
"""Tests for db/species.py"""
from unittest import TestCase
from unittest import mock
import pytest
from gn3.db.species import get_chromosome
from gn3.db.species import get_all_species
class TestChromosomes(TestCase):
"""Test cases for fetching chromosomes"""
@pytest.mark.unit_test
@pytest.mark.skip
def test_get_chromosome_using_species_name(self):
"""Test that the chromosome is fetched using a species name"""
db_mock = mock.MagicMock()
with db_mock.cursor() as cursor:
cursor.fetchall.return_value = ()
self.assertEqual(get_chromosome(name="TestCase",
is_species=True,
conn=db_mock), ())
cursor.execute.assert_called_once_with(
"SELECT Chr_Length.Name, Chr_Length.OrderId, "
"Length FROM Chr_Length, Species WHERE "
"Chr_Length.SpeciesId = Species.SpeciesId AND "
"Species.Name = 'TestCase' ORDER BY OrderId"
)
@pytest.mark.unit_test
@pytest.mark.skip
def test_get_chromosome_using_group_name(self):
"""Test that the chromosome is fetched using a group name"""
db_mock = mock.MagicMock()
with db_mock.cursor() as cursor:
cursor.fetchall.return_value = ()
self.assertEqual(get_chromosome(name="TestCase",
is_species=False,
conn=db_mock), ())
cursor.execute.assert_called_once_with(
"SELECT Chr_Length.Name, Chr_Length.OrderId, "
"Length FROM Chr_Length, InbredSet WHERE "
"Chr_Length.SpeciesId = InbredSet.SpeciesId AND "
"InbredSet.Name = 'TestCase' ORDER BY OrderId"
)
@pytest.mark.unit_test
@pytest.mark.skip
def test_get_all_species(self):
"""Test that species are fetched correctly"""
db_mock = mock.MagicMock()
with db_mock.cursor() as cursor:
cursor.fetchall.return_value = ()
self.assertEqual(get_all_species(db_mock), ())
cursor.execute.assert_called_once_with(
"SELECT Name, MenuName, IFNULL(Family, 'None') "
"FROM Species "
"ORDER BY IFNULL(FamilyOrderId, SpeciesName) ASC, "
"IFNULL(Family, SpeciesName) ASC, "
"OrderId ASC"
)
|