def check(): c = PostgreSql('postgres', {}, [{ 'dbname': 'dbname', 'host': 'localhost', 'port': '5432' }]) c._version = VersionInfo(9, 2, 0) return c
def test_get_instance_with_default(pg_instance, collect_default_database): """ Test the contents of the query string with different `collect_default_database` values """ pg_instance['collect_default_database'] = collect_default_database check = PostgreSql('postgres', {}, [pg_instance]) check._version = VersionInfo(9, 2, 0) res = check.metrics_cache.get_instance_metrics(check._version) dbfilter = " AND psd.datname not ilike 'postgres'" if collect_default_database: assert dbfilter not in res['query'] else: assert dbfilter in res['query']