diff options
author | BonfaceKilz | 2021-05-08 16:03:37 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-05-08 19:19:47 +0300 |
commit | 7076597adea0d05bc5f9219266b870d03f9bfd24 (patch) | |
tree | 552921eee0dcd9482187d0d0719c21f3b7f1e8ef | |
parent | a460bab0b127c4c992e36a26e3882d863909df0a (diff) | |
download | genenetwork3-7076597adea0d05bc5f9219266b870d03f9bfd24.tar.gz |
tests: test_species: New tests
-rw-r--r-- | tests/unit/db/__init__.py | 0 | ||||
-rw-r--r-- | tests/unit/db/test_species.py | 38 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/unit/db/__init__.py b/tests/unit/db/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/unit/db/__init__.py diff --git a/tests/unit/db/test_species.py b/tests/unit/db/test_species.py new file mode 100644 index 0000000..43b5f51 --- /dev/null +++ b/tests/unit/db/test_species.py @@ -0,0 +1,38 @@ +"""Tests for db/species.py""" +from unittest import TestCase +from unittest import mock + +from gn3.db.species import get_chromosome + + +class TestChromosomes(TestCase): + """Test cases for fetching chromosomes""" + 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" + ) + + 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" + ) |