def test_remove_schema(self): """after remove, a schema should no longer exist""" url = "pg://localhost:5432/tuttle_test_db/test_schema/" res = PostgreSQLResource(url) assert res.exists(), "{} should exist".format(url) res.remove() assert not res.exists(), "{} should not exist anymore".format(url)
def test_table_signature(self): """signature() should return a hash of the structure and the data for a table""" url = "pg://localhost:5432/tuttle_test_db/test_table" res = PostgreSQLResource(url) sig = res.signature() expected = "a545767cf5742cb647ac7b507ac77960d737474a" assert sig == expected, sig
def test_schema_exists(self): """exists() should return True because the schema exists""" url = "pg://localhost:5432/tuttle_test_db/test_schema/" res = PostgreSQLResource(url) msg = " server : {}\n port : {}\ndb : {} \nschema : {}\n object {}".format(res._server, res._port, res._database, res._schema, res._objectname) assert res.exists(), msg assert res.exists(), "{} should exist".format(url)
def test_remove_function_with_args(self): """after remove, a function should no longer exist whatever its arguments""" url = "pg://localhost:5432/tuttle_test_db/test_function_args" res = PostgreSQLResource(url) assert res.exists(), "{} should exist".format(url) res.remove() assert not res.exists(), "{} should not exist anymore".format(url)
def test_remove_table(self): """remove() should remove a table""" url = "pg://localhost:5432/tuttle_test_db/test_table" res = PostgreSQLResource(url) assert res.exists(), "{} should exist".format(url) res.remove() assert not res.exists(), "{} should not exist".format(url)
def test_view_signature(self): """the declaration of a view should be its signature""" url = "pg://localhost:5432/tuttle_test_db/test_view" res = PostgreSQLResource(url) assert res.exists(), "{} should exist".format(url) expected = "SELECT test_table.col1 FROM test_table;" sig = res.signature() assert self.clean_view_sig(sig) == expected, sig
def test_pg_table_not_exists(self): """the table should not exist""" url = "pg://localhost:5432/tuttle_test_db/no_table" res = PostgreSQLResource(url) assert not res.exists(), "{} should exist".format(url)
def test_pg_table_exists(self): """exists() should return True when the table exists""" url = "pg://localhost:5432/tuttle_test_db/test_table" res = PostgreSQLResource(url) assert res.exists(), "{} should exist".format(url)
def test_dont_mix_schema_and_object_signature(self): """If we omit the / at the end of the resource, it should not be interpreted as a schema""" url = "pg://localhost:5432/tuttle_test_db/test_schema" res = PostgreSQLResource(url) assert not res.exists(), "{} should not exist because no table, view nor any object with that name " \ "exists".format(url)
def test_schema_signature(self): """the signature of the schema should be its owner""" url = "pg://localhost:5432/tuttle_test_db/test_schema/" res = PostgreSQLResource(url) assert res.exists(), "{} should exist".format(url) assert res.signature().startswith("owner : "), res.signature()
def test_function_signature(self): """the signature of a function should be a hash of its source code""" url = "pg://localhost:5432/tuttle_test_db/test_function_args" res = PostgreSQLResource(url) assert res.exists(), "{} should exist".format(url) assert res.signature() == "b92433deca9384c90d6313f496ea4b67d5531983", res.signature()
def test_function_exists(self): """exists() should return True because the function exists""" url = "pg://localhost:5432/tuttle_test_db/test_function" res = PostgreSQLResource(url) assert res.exists(), "{} should exist".format(url)
def test_pg_table_outside_schema_does_not_exist(self): """the table should exist if it isn't in the proper schema""" url = "pg://localhost:5432/tuttle_test_db/test_schema/test_table" res = PostgreSQLResource(url) assert not res.exists(), "{} should not exist".format(url)
def test_pg_table_with_schema_exists(self): """exists() the table should exist in the schema""" url = "pg://localhost:5432/tuttle_test_db/test_schema/test_table_in_schema" res = PostgreSQLResource(url) assert res.exists(), "{} should exist".format(url)