def test_execute_statement_10(self):
     """Verify invalid data can be inserted after '% w' is
     replaced with '%% w'."""
     domain_data = test_data_utils.get_trixie_domain_data()
     # "Description": "ParB-like nuclease domain"
     description = domain_data["Description"]
     description = description.replace("nuclease domain",
                                       "nuclease % wdomain")
     domain_data["Description"] = description
     statement = get_domain_insert_statement(domain_data)
     statement = statement.replace("%", "%%")
     results_tup = find_domains.execute_statement(self.connection,
                                                  statement)
     result = results_tup[0]
     type_error = results_tup[1]
     value_error = results_tup[2]
     msg = results_tup[3]
     self.trans.commit()
     domain_table_results = test_db_utils.get_data(
         test_db_utils.domain_table_query)
     with self.subTest():
         self.assertEqual(len(domain_table_results), 1)
     with self.subTest():
         self.assertEqual(result, 0)
     with self.subTest():
         self.assertFalse(type_error)
     with self.subTest():
         self.assertFalse(value_error)
 def test_execute_statement_6(self):
     """Verify invalid data can NOT be inserted into domain table when
     there is an invalid column name."""
     domain_data = test_data_utils.get_trixie_domain_data()
     statement = get_domain_insert_statement(domain_data)
     statement = statement.replace("Name", "Name_invalid")
     results_tup = find_domains.execute_statement(self.connection,
                                                  statement)
     result = results_tup[0]
     type_error = results_tup[1]
     value_error = results_tup[2]
     msg = results_tup[3]
     self.trans.commit()
     domain_table_results = test_db_utils.get_data(
         test_db_utils.domain_table_query)
     with self.subTest():
         self.assertEqual(len(domain_table_results), 0)
     with self.subTest():
         self.assertEqual(result, 1)
     with self.subTest():
         self.assertTrue(error_msg in msg)
     with self.subTest():
         self.assertFalse(type_error)
     with self.subTest():
         self.assertFalse(value_error)
 def test_execute_statement_5(self):
     """Verify invalid data can NOT be inserted into domain table when
     there is a duplicated HitID."""
     domain_data = test_data_utils.get_trixie_domain_data()
     statement = get_domain_insert_statement(domain_data)
     results_tup1 = find_domains.execute_statement(self.connection,
                                                   statement)
     result1 = results_tup1[0]
     type_error1 = results_tup1[1]
     value_error1 = results_tup1[2]
     msg1 = results_tup1[3]
     self.trans.commit()
     domain_table_results1 = test_db_utils.get_data(
         test_db_utils.domain_table_query)
     new_trans = self.connection.begin()
     results_tup2 = find_domains.execute_statement(self.connection,
                                                   statement)
     result2 = results_tup2[0]
     type_error2 = results_tup2[1]
     value_error2 = results_tup2[2]
     msg2 = results_tup2[3]
     new_trans.commit()
     domain_table_results2 = test_db_utils.get_data(
         test_db_utils.domain_table_query)
     with self.subTest():
         self.assertEqual(len(domain_table_results1), 1)
     with self.subTest():
         self.assertEqual(len(domain_table_results2), 1)
     with self.subTest():
         self.assertEqual(result1, 0)
     with self.subTest():
         self.assertEqual(result2, 0)
     with self.subTest():
         self.assertFalse(type_error1)
     with self.subTest():
         self.assertFalse(type_error2)
     with self.subTest():
         self.assertFalse(value_error1)
     with self.subTest():
         self.assertFalse(value_error2)
     with self.subTest():
         self.assertFalse(error_msg in msg1)
     with self.subTest():
         self.assertTrue(error_msg in msg2)
 def test_execute_statement_3(self):
     """Verify valid data can be inserted into domain and gene_domain tables."""
     domain_data = test_data_utils.get_trixie_domain_data()
     statement1 = get_domain_insert_statement(domain_data)
     results_tup1 = find_domains.execute_statement(self.connection,
                                                   statement1)
     result1 = results_tup1[0]
     type_error1 = results_tup1[1]
     value_error1 = results_tup1[2]
     msg1 = results_tup1[3]
     gene_domain_data = test_data_utils.get_trixie_gene_domain_data()
     statement2 = get_gene_domain_insert_statement(gene_domain_data)
     results_tup2 = find_domains.execute_statement(self.connection,
                                                   statement2)
     result2 = results_tup2[0]
     type_error2 = results_tup2[1]
     value_error2 = results_tup2[2]
     msg2 = results_tup2[3]
     self.trans.commit()
     gene_domain_table_results = test_db_utils.get_data(
         test_db_utils.gene_domain_table_query)
     domain_table_results = test_db_utils.get_data(
         test_db_utils.domain_table_query)
     with self.subTest():
         self.assertEqual(len(domain_table_results), 1)
     with self.subTest():
         self.assertEqual(len(gene_domain_table_results), 1)
     with self.subTest():
         self.assertEqual(result1, 0)
     with self.subTest():
         self.assertEqual(result2, 0)
     with self.subTest():
         self.assertFalse(type_error1)
     with self.subTest():
         self.assertFalse(type_error2)
     with self.subTest():
         self.assertFalse(value_error1)
     with self.subTest():
         self.assertFalse(value_error2)
 def test_execute_statement_1(self):
     """Verify valid DomainStatus update data can be inserted
     into gene table."""
     gene_table_results1 = test_db_utils.get_data(
         test_db_utils.gene_table_query)
     update_data = get_trixie_gene_table_domain_status_update_data_1()
     statement = get_gene_update_statement(update_data)
     results_tup = find_domains.execute_statement(self.connection,
                                                  statement)
     result = results_tup[0]
     type_error = results_tup[1]
     value_error = results_tup[2]
     msg = results_tup[3]
     self.trans.commit()
     phage_table_results = test_db_utils.get_data(
         test_db_utils.phage_table_query)
     gene_table_results2 = test_db_utils.get_data(
         test_db_utils.gene_table_query)
     gene_domain_table_results = test_db_utils.get_data(
         test_db_utils.gene_domain_table_query)
     domain_table_results = test_db_utils.get_data(
         test_db_utils.domain_table_query)
     domain_status1 = gene_table_results1[0]["DomainStatus"]
     domain_status2 = gene_table_results2[0]["DomainStatus"]
     with self.subTest():
         self.assertEqual(len(phage_table_results), 1)
     with self.subTest():
         self.assertEqual(len(gene_table_results2), 1)
     with self.subTest():
         self.assertEqual(len(domain_table_results), 0)
     with self.subTest():
         self.assertEqual(len(gene_domain_table_results), 0)
     with self.subTest():
         self.assertEqual(domain_status1, 0)
     with self.subTest():
         self.assertEqual(domain_status2, 1)
     with self.subTest():
         self.assertEqual(result, 0)
     with self.subTest():
         self.assertFalse(type_error)
     with self.subTest():
         self.assertFalse(value_error)
     with self.subTest():
         self.assertIsInstance(msg, str)
 def test_execute_statement_2(self):
     """Verify valid data can be inserted into domain table."""
     domain_data = test_data_utils.get_trixie_domain_data()
     statement = get_domain_insert_statement(domain_data)
     results_tup = find_domains.execute_statement(self.connection,
                                                  statement)
     result = results_tup[0]
     type_error = results_tup[1]
     value_error = results_tup[2]
     msg = results_tup[3]
     self.trans.commit()
     domain_table_results = test_db_utils.get_data(
         test_db_utils.domain_table_query)
     with self.subTest():
         self.assertEqual(len(domain_table_results), 1)
     with self.subTest():
         self.assertEqual(result, 0)
     with self.subTest():
         self.assertFalse(type_error)
     with self.subTest():
         self.assertFalse(value_error)
 def test_execute_statement_4(self):
     """Verify invalid data can NOT be inserted into gene_domain table
     when there is no matching 'HitID' in the domain table."""
     gene_domain_data = test_data_utils.get_trixie_gene_domain_data()
     statement = get_gene_domain_insert_statement(gene_domain_data)
     results_tup = find_domains.execute_statement(self.connection,
                                                  statement)
     result = results_tup[0]
     type_error = results_tup[1]
     value_error = results_tup[2]
     msg = results_tup[3]
     self.trans.commit()
     gene_domain_table_results = test_db_utils.get_data(
         test_db_utils.gene_domain_table_query)
     with self.subTest():
         self.assertEqual(len(gene_domain_table_results), 0)
     with self.subTest():
         self.assertEqual(result, 1)
     with self.subTest():
         self.assertFalse(type_error)
     with self.subTest():
         self.assertFalse(value_error)