コード例 #1
0
    def test_get_gene_id_for_endpoints(self):

        con = mock_DatabaseConnector()
        con.insert_many(
            "genes",
            [
                {"head": 1, "tail": 2},
                {"head": 1, "tail": 3},
                {"head": 3, "tail": 2},
                {"head": 1, "tail": 4},
                {"head": 4, "tail": 3},
                {"head": 5, "tail": 2}
            ]
        )
        gene_repo = GeneRepository(con)

        gene_id = gene_repo.get_gene_id_for_endpoints(1, 2)
        self.assertEqual(
            gene_id,
            0,
            "The GeneRepository didn't find the appropriate gene_id for endpoints."
        )

        gene_id = gene_repo.get_gene_id_for_endpoints(3, 2)
        self.assertEqual(
            gene_id,
            2,
            "The GeneRepository didn't find the appropriate gene_id for endpoints."
        )

        gene_id = gene_repo.get_gene_id_for_endpoints(4, 3)
        self.assertEqual(
            gene_id,
            4,
            "The GeneRepository didn't find the appropriate gene_id for endpoints."
        )

        gene_id = gene_repo.get_gene_id_for_endpoints(10, 20)
        self.assertEqual(
            gene_id,
            6,
            "The GeneRepository didn't find the appropriate gene_id for endpoints."
        )