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)
def test_that_data_accessor_is_not_vulnerable_to_sql_injections(self): with self.assertRaises(QuerioDatabaseError): DataAccessor(self.postgresql.url(), "shop; DROP TABLE car;")
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;")
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")
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")
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)
def test_create_data_accessor_with_invalid_db_address(self): with self.assertRaises(QuerioDatabaseError): DataAccessor("postgres://*****:*****@evilhost:666/scamdb", "car")
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)
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()
def test_create_data_accessor_with_invalid_table_name(self): with self.assertRaises(QuerioDatabaseError): DataAccessor(self.postgresql.url(), "animal")