Exemple #1
0
 def test_null_count(self):
     da = DataAccessor(self.postgresql.url(), "car")
     nullmsg = da.get_null_count()
     self.assertEqual("There are 1 rows with null values. These rows have been ignored.", nullmsg)
Exemple #2
0
 def test_that_data_accessor_is_not_vulnerable_to_sql_injections(self):
     with self.assertRaises(QuerioDatabaseError):
         DataAccessor(self.postgresql.url(), "shop; DROP TABLE car;")
Exemple #3
0
 def test_that_pop_var_is_not_vulnerable_to_sql_injections(self):
     da = DataAccessor(self.postgresql.url(), "car")
     with self.assertRaises(QuerioDatabaseError):
         da.get_population_variance_from_db("car_price; DROP TABLE shop;")
Exemple #4
0
 def test_get_population_variance_from_varchar_columns(self):
     da = DataAccessor(self.postgresql.url(), "car")
     with self.assertRaises(QuerioDatabaseError):
         da.get_population_variance_from_db("car_name")
Exemple #5
0
 def test_pop_var_with_invalid_column_name(self):
     da = DataAccessor(self.postgresql.url(), "car")
     with self.assertRaises(QuerioDatabaseError):
         da.get_population_variance_from_db("not_existing")
Exemple #6
0
 def test_get_population_variance_from_integer_columns(self):
     da = DataAccessor(self.postgresql.url(), "car")
     result = da.get_population_variance_from_db("car_price")
     self.assertIsNotNone(result)
Exemple #7
0
 def test_create_data_accessor_with_invalid_db_address(self):
     with self.assertRaises(QuerioDatabaseError):
         DataAccessor("postgres://*****:*****@evilhost:666/scamdb", "car")
Exemple #8
0
 def test_get_example_row_if_table_not_empty(self):
     da = DataAccessor(self.postgresql.url(), "car")
     result = da.get_example_row_from_db()
     self.assertGreater(len(result), 0)
Exemple #9
0
 def test_get_example_row_if_table_empty(self):
     da = DataAccessor(self.postgresql.url(), "shop")
     with self.assertRaises(QuerioDatabaseError):
         da.get_example_row_from_db()
Exemple #10
0
 def test_create_data_accessor_with_invalid_table_name(self):
     with self.assertRaises(QuerioDatabaseError):
         DataAccessor(self.postgresql.url(), "animal")