Esempio n. 1
0
 def test_add_edges(self):
     """
     Tests whether new rows are added to the edges table.
     :return:
     """
     conn_object = BiomConnection()
     conn_object.create_tables()
     conn_object.add_biom(testbiom, 'banana')
     conn_object = IoConnection()
     conn_object.add_network_node(values=("banana", "banana", 2, 3))
     conn_object.add_edge(
         values=[("banana", "GG_OTU_1", "GG_OTU_2",
                  0.3), ("banana", "GG_OTU_3", "GG_OTU_5", -0.8)])
     conn = psycopg2.connect(
         **{
             "host": "localhost",
             "database": "test",
             "user": "******",
             "password": "******"
         })
     cur = conn.cursor()
     cur.execute("SELECT * from edges;")
     result = cur.fetchall()
     cur.close()
     conn.close()
     conn_object.delete_tables()
     self.assertEqual(len(result), 2)
Esempio n. 2
0
 def test_edge_error(self):
     """
     Tests if the query correctly reports an error
     when network data is not present
     :return:
     """
     conn_object = BiomConnection()
     conn_object.create_tables()
     conn_object.add_biom(testbiom, 'banana')
     conn_object = IoConnection()
     self.assertRaises(
         psycopg2.Error,
         conn_object.add_edge(values=('apple', 'Streptococcus', 'Sample1',
                                      0.5)),
     )
     # long format table of 5 * 6 observations
     conn_object.delete_tables()