-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_hydra.py
More file actions
49 lines (37 loc) · 1.33 KB
/
test_hydra.py
File metadata and controls
49 lines (37 loc) · 1.33 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
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
def test_hydra():
# ---------- 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)
rs = hydra_upload(
DBClient=DBClient,
TargetTableName=table,
SourceFilePath=CURRENT_DIRECTORY+"/test_hydra_cities.csv",
UploadMethod='File'
)
print(rs)
assert rs['result']=='OK'
# ------------ Retreive Table from Hydra -------------
rs = hydra_download(
DBClient=DBClient,
SourceTableName=table,
DownloadMethod="File",
LocalFilePath=CURRENT_DIRECTORY+"/test_cities_delete.csv",
)
print(rs)
assert rs["result"]=="OK"