2020-02-13 12:14:02 +03:00
|
|
|
import pytest
|
2019-09-04 18:02:35 +03:00
|
|
|
import ruamel.yaml as yaml
|
2019-04-30 11:34:08 +03:00
|
|
|
import os
|
|
|
|
|
|
|
|
resp_pg_version_map = {
|
|
|
|
'9_5': 'response_9',
|
|
|
|
'9_6': 'response_9',
|
2019-10-26 08:39:57 +03:00
|
|
|
'10': 'response_10_11',
|
|
|
|
'11': 'response_10_11',
|
|
|
|
'12': 'response_10_11',
|
2020-12-01 15:21:45 +03:00
|
|
|
'13': 'response_10_11',
|
2019-04-30 11:34:08 +03:00
|
|
|
'latest': 'response_10_11'
|
|
|
|
}
|
|
|
|
|
2020-02-13 12:14:02 +03:00
|
|
|
@pytest.mark.usefixtures('per_method_tests_db_state')
|
|
|
|
class TestPGDump:
|
2019-04-30 11:34:08 +03:00
|
|
|
|
|
|
|
def test_pg_dump_for_public_schema(self, hge_ctx):
|
|
|
|
query_file = self.dir() + '/pg_dump_public.yaml'
|
|
|
|
PG_VERSION = os.getenv('PG_VERSION', 'latest')
|
|
|
|
with open(query_file, 'r') as stream:
|
|
|
|
q = yaml.safe_load(stream)
|
|
|
|
headers = {}
|
|
|
|
if hge_ctx.hge_key is not None:
|
|
|
|
headers['x-hasura-admin-secret'] = hge_ctx.hge_key
|
|
|
|
resp = hge_ctx.http.post(hge_ctx.hge_url + q['url'], json=q['query'], headers=headers)
|
|
|
|
body = resp.text
|
|
|
|
assert resp.status_code == q['status']
|
2020-02-13 12:14:02 +03:00
|
|
|
print(body)
|
|
|
|
print(q[resp_pg_version_map[PG_VERSION]])
|
2019-04-30 11:34:08 +03:00
|
|
|
assert body == q[resp_pg_version_map[PG_VERSION]]
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "pgdump"
|