forked from hasura/graphql-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_pg_dump.py
30 lines (26 loc) · 976 Bytes
/
test_pg_dump.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import yaml
from super_classes import DefaultTestSelectQueries
import os
resp_pg_version_map = {
'9_5': 'response_9',
'9_6': 'response_9',
'10_6': 'response_10_11',
'11_1': 'response_10_11',
'latest': 'response_10_11'
}
class TestPGDump(DefaultTestSelectQueries):
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']
assert body == q[resp_pg_version_map[PG_VERSION]]
@classmethod
def dir(cls):
return "pgdump"