-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_hydra_object.py
More file actions
52 lines (40 loc) · 1.38 KB
/
test_hydra_object.py
File metadata and controls
52 lines (40 loc) · 1.38 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import sqlalchemy
from .hydra_download import hydra_download
from .hydra_upload import hydra_upload
import os
from dotenv import load_dotenv
from nanoid import generate
from io import BytesIO
def test_hydra_object():
# ---------- DATAPLANE RUN ------------
# Dataplane run id
os.environ["DP_RUNID"] = generate('1234567890abcdef', 10)
# Sharepoint connection
load_dotenv()
RUN_ID = os.environ["DP_RUNID"]
DBClient = sqlalchemy.create_engine("postgresql://admin:hello123@hydra:5432/dataplanedb?sslmode=disable")
table = 'newtable'
CURRENT_DIRECTORY = os.path.realpath(os.path.dirname(__file__))
if os.path.exists(CURRENT_DIRECTORY+"/test_cities_delete_object.csv"):
os.remove(CURRENT_DIRECTORY+"/test_cities_delete_object.csv")
# ------------- Store file to Hydra DB -------------
print(CURRENT_DIRECTORY)
with open(CURRENT_DIRECTORY+"/test_hydra_cities.csv",'rb') as f:
buf = BytesIO(f.read())
buf.seek(0)
rs = hydra_upload(
DBClient=DBClient,
TargetTableName=table,
UploadObject=buf,
UploadMethod='Object'
)
print(rs)
assert rs['result']=='OK'
# ------------ Retreive Table from Hydra -------------
rs = hydra_download(
DBClient=DBClient,
SourceTableName=table,
DownloadMethod="Object",
)
print(rs)
assert rs["result"]=="OK"