msfabricpysdkcore 0.2.2__py3-none-any.whl → 0.2.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- msfabricpysdkcore/adminapi.py +114 -0
- msfabricpysdkcore/coreapi.py +1216 -53
- msfabricpysdkcore/deployment_pipeline.py +101 -28
- msfabricpysdkcore/domain.py +4 -1
- msfabricpysdkcore/eventstream.py +68 -0
- msfabricpysdkcore/folder.py +69 -0
- msfabricpysdkcore/item.py +9 -0
- msfabricpysdkcore/lakehouse.py +9 -1
- msfabricpysdkcore/otheritems.py +59 -40
- msfabricpysdkcore/tests/test_admin_tags.py +46 -0
- msfabricpysdkcore/tests/test_copy_jobs.py +60 -0
- msfabricpysdkcore/tests/test_dataflows.py +60 -0
- msfabricpysdkcore/tests/test_datapipelines.py +44 -29
- msfabricpysdkcore/tests/test_deployment_pipelinev2.py +135 -0
- msfabricpysdkcore/tests/test_eventstream_topology.py +82 -0
- msfabricpysdkcore/tests/test_folders.py +53 -0
- msfabricpysdkcore/tests/test_tags.py +28 -0
- msfabricpysdkcore/tests/test_variable_libary.py +61 -0
- msfabricpysdkcore/workspace.py +354 -0
- {msfabricpysdkcore-0.2.2.dist-info → msfabricpysdkcore-0.2.4.dist-info}/METADATA +226 -24
- {msfabricpysdkcore-0.2.2.dist-info → msfabricpysdkcore-0.2.4.dist-info}/RECORD +24 -14
- {msfabricpysdkcore-0.2.2.dist-info → msfabricpysdkcore-0.2.4.dist-info}/WHEEL +1 -1
- {msfabricpysdkcore-0.2.2.dist-info → msfabricpysdkcore-0.2.4.dist-info/licenses}/LICENSE +0 -0
- {msfabricpysdkcore-0.2.2.dist-info → msfabricpysdkcore-0.2.4.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
import unittest
|
2
|
+
from dotenv import load_dotenv
|
3
|
+
from msfabricpysdkcore import FabricClientCore
|
4
|
+
from datetime import datetime
|
5
|
+
load_dotenv()
|
6
|
+
|
7
|
+
class TestFabricClientCore(unittest.TestCase):
|
8
|
+
|
9
|
+
def __init__(self, *args, **kwargs):
|
10
|
+
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
11
|
+
self.fcc = FabricClientCore()
|
12
|
+
|
13
|
+
def test_dataflows(self):
|
14
|
+
fcc = self.fcc
|
15
|
+
|
16
|
+
workspace_id = "05bc5baa-ef02-4a31-ab20-158a478151d3"
|
17
|
+
item_id = "8bc6f2f1-2ef9-4dc1-ab47-f55aa90e4088"
|
18
|
+
|
19
|
+
dataflows = fcc.list_dataflows(workspace_id=workspace_id)
|
20
|
+
for dataflow in dataflows:
|
21
|
+
if dataflow.id != item_id:
|
22
|
+
resp = fcc.delete_dataflow(workspace_id=workspace_id, dataflow_id=dataflow.id)
|
23
|
+
self.assertEqual(resp, 200)
|
24
|
+
|
25
|
+
dataflow_definition = fcc.get_dataflow_definition(workspace_id=workspace_id, dataflow_id=item_id)
|
26
|
+
self.assertIn("definition", dataflow_definition)
|
27
|
+
definition = dataflow_definition["definition"]
|
28
|
+
|
29
|
+
date_str = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
30
|
+
date_str = date_str.replace(" ", "T").replace(":", "").replace("-", "")
|
31
|
+
date_str = f"dataflow{date_str}"
|
32
|
+
|
33
|
+
dataflow_new = fcc.create_dataflow(workspace_id=workspace_id, display_name=date_str, definition=definition)
|
34
|
+
|
35
|
+
self.assertEqual(dataflow_new.display_name, date_str)
|
36
|
+
|
37
|
+
dataflow_get = fcc.get_dataflow(workspace_id=workspace_id, dataflow_id=dataflow_new.id)
|
38
|
+
self.assertEqual(dataflow_get.display_name, date_str)
|
39
|
+
|
40
|
+
dataflows = fcc.list_dataflows(workspace_id=workspace_id)
|
41
|
+
self.assertEqual(len(dataflows), 2)
|
42
|
+
|
43
|
+
date_str_updated = date_str + "_updated"
|
44
|
+
dataflow_updated = fcc.update_dataflow(workspace_id=workspace_id, dataflow_id=dataflow_new.id, display_name=date_str_updated, return_item=True)
|
45
|
+
self.assertEqual(dataflow_updated.display_name, date_str_updated)
|
46
|
+
|
47
|
+
dataflow_updated = fcc.update_dataflow_definition(workspace_id=workspace_id, dataflow_id=dataflow_new.id, definition=definition)
|
48
|
+
self.assertEqual(dataflow_updated.status_code, 200)
|
49
|
+
|
50
|
+
for dataflow in dataflows:
|
51
|
+
if dataflow.id != item_id:
|
52
|
+
resp = fcc.delete_dataflow(workspace_id=workspace_id, dataflow_id=dataflow.id)
|
53
|
+
self.assertEqual(resp, 200)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
@@ -1,45 +1,60 @@
|
|
1
1
|
import unittest
|
2
|
-
from datetime import datetime
|
3
2
|
from dotenv import load_dotenv
|
4
|
-
from
|
5
|
-
from
|
6
|
-
|
3
|
+
from msfabricpysdkcore import FabricClientCore
|
4
|
+
from datetime import datetime
|
7
5
|
load_dotenv()
|
8
6
|
|
9
7
|
class TestFabricClientCore(unittest.TestCase):
|
10
8
|
|
11
9
|
def __init__(self, *args, **kwargs):
|
12
10
|
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
self.fcc = FabricClientCore()
|
12
|
+
|
16
13
|
def test_data_pipelines(self):
|
14
|
+
fcc = self.fcc
|
15
|
+
|
16
|
+
workspace_id = "05bc5baa-ef02-4a31-ab20-158a478151d3"
|
17
|
+
item_id = "b7746e38-5409-487a-969c-fb7cb026b5d3"
|
18
|
+
|
19
|
+
data_pipelines = fcc.list_data_pipelines(workspace_id=workspace_id)
|
20
|
+
for data_pipeline in data_pipelines:
|
21
|
+
if data_pipeline.id != item_id:
|
22
|
+
resp = fcc.delete_data_pipeline(workspace_id=workspace_id, data_pipeline_id=data_pipeline.id)
|
23
|
+
self.assertEqual(resp, 200)
|
24
|
+
|
25
|
+
data_pipeline_definition = fcc.get_data_pipeline_definition(workspace_id=workspace_id, data_pipeline_id=item_id)
|
26
|
+
self.assertIn("definition", data_pipeline_definition)
|
27
|
+
definition = data_pipeline_definition["definition"]
|
28
|
+
|
29
|
+
date_str = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
30
|
+
date_str = date_str.replace(" ", "T").replace(":", "").replace("-", "")
|
31
|
+
date_str = f"data_pipeline{date_str}"
|
32
|
+
|
33
|
+
data_pipeline_new = fcc.create_data_pipeline(workspace_id=workspace_id, display_name=date_str, definition=definition)
|
34
|
+
|
35
|
+
self.assertEqual(data_pipeline_new.display_name, date_str)
|
36
|
+
|
37
|
+
data_pipeline_get = fcc.get_data_pipeline(workspace_id=workspace_id, data_pipeline_id=data_pipeline_new.id)
|
38
|
+
self.assertEqual(data_pipeline_get.display_name, date_str)
|
39
|
+
|
40
|
+
data_pipelines = fcc.list_data_pipelines(workspace_id=workspace_id)
|
41
|
+
self.assertEqual(len(data_pipelines), 2)
|
42
|
+
|
43
|
+
date_str_updated = date_str + "_updated"
|
44
|
+
data_pipeline_updated = fcc.update_data_pipeline(workspace_id=workspace_id, data_pipeline_id=data_pipeline_new.id, display_name=date_str_updated, return_item=True)
|
45
|
+
self.assertEqual(data_pipeline_updated.display_name, date_str_updated)
|
46
|
+
|
47
|
+
data_pipeline_updated = fcc.update_data_pipeline_definition(workspace_id=workspace_id, data_pipeline_id=data_pipeline_new.id, definition=definition)
|
48
|
+
self.assertEqual(data_pipeline_updated.status_code, 200)
|
49
|
+
|
50
|
+
for data_pipeline in data_pipelines:
|
51
|
+
if data_pipeline.id != item_id:
|
52
|
+
resp = fcc.delete_data_pipeline(workspace_id=workspace_id, data_pipeline_id=data_pipeline.id)
|
53
|
+
self.assertEqual(resp, 200)
|
17
54
|
|
18
|
-
fc = self.fc
|
19
|
-
workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
|
20
|
-
datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
|
21
|
-
pipeline_name = f"pipeline_{datetime_str}"
|
22
55
|
|
23
|
-
dp = fc.create_data_pipeline(workspace_id, display_name=pipeline_name, description="asda")
|
24
|
-
dp.update_definition(dp.definition)
|
25
56
|
|
26
|
-
dps = fc.list_data_pipelines(workspace_id)
|
27
|
-
dp_names = [dp.display_name for dp in dps]
|
28
|
-
self.assertGreater(len(dps), 0)
|
29
|
-
self.assertIn(pipeline_name, dp_names)
|
30
57
|
|
31
|
-
self.assertEqual(dp.display_name, pipeline_name)
|
32
|
-
pipeline_name2 = f"pipeline_{datetime_str}_2"
|
33
|
-
dp2 = fc.update_data_pipeline(workspace_id, dp.id, display_name=pipeline_name2, return_item=True)
|
34
58
|
|
35
|
-
dp = fc.get_data_pipeline(workspace_id, data_pipeline_id=dp.id)
|
36
|
-
self.assertEqual(dp.display_name, pipeline_name2)
|
37
|
-
self.assertEqual(dp.id, dp2.id)
|
38
59
|
|
39
|
-
dp2 = fc.update_data_pipeline(workspace_id, dp.id, display_name=pipeline_name, return_item=True)
|
40
60
|
|
41
|
-
dp = fc.get_data_pipeline(workspace_id, data_pipeline_id=dp.id)
|
42
|
-
self.assertEqual(dp.display_name, pipeline_name)
|
43
|
-
self.assertEqual(dp.id, dp2.id)
|
44
|
-
status_code = fc.delete_data_pipeline(workspace_id, dp.id)
|
45
|
-
self.assertEqual(status_code, 200)
|
@@ -0,0 +1,135 @@
|
|
1
|
+
import unittest
|
2
|
+
from msfabricpysdkcore.coreapi import FabricClientCore
|
3
|
+
from datetime import datetime
|
4
|
+
from dotenv import load_dotenv
|
5
|
+
import time
|
6
|
+
|
7
|
+
load_dotenv()
|
8
|
+
|
9
|
+
class TestFabricClientCore(unittest.TestCase):
|
10
|
+
|
11
|
+
def __init__(self, *args, **kwargs):
|
12
|
+
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
13
|
+
#load_dotenv()
|
14
|
+
self.fc = FabricClientCore()
|
15
|
+
|
16
|
+
def test_deployment_pipeline2(self):
|
17
|
+
fcc = self.fc
|
18
|
+
workspace_id = "72d9d955-bd1e-42c7-9746-208f7cbc8956"
|
19
|
+
|
20
|
+
user_id = "e0505016-ef55-4ca7-b106-e085cc201823"
|
21
|
+
capacity_id = "9e7e757d-d567-4fb3-bc4f-d230aabf2a00"
|
22
|
+
|
23
|
+
prod_workspace = fcc.create_workspace("sdkswedenproddeploy")
|
24
|
+
prod_workspace.assign_to_capacity(capacity_id)
|
25
|
+
|
26
|
+
stages = [
|
27
|
+
{
|
28
|
+
"displayName": "Development",
|
29
|
+
"description": "Development stage description",
|
30
|
+
"isPublic": False
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"displayName": "Production",
|
34
|
+
"description": "Production stage description",
|
35
|
+
"isPublic":True
|
36
|
+
}
|
37
|
+
]
|
38
|
+
|
39
|
+
pipes = fcc.list_deployment_pipelines(with_details=False)
|
40
|
+
for pipe in pipes:
|
41
|
+
if "sdk" in pipe["displayName"]:
|
42
|
+
fcc.delete_deployment_pipeline(deployment_pipeline_id=pipe["id"])
|
43
|
+
|
44
|
+
pipe =fcc.create_deployment_pipeline(display_name="sdktestpipeline",
|
45
|
+
description="Test Deployment Pipeline Description",
|
46
|
+
stages=stages)
|
47
|
+
|
48
|
+
self.assertIsNotNone(pipe.id)
|
49
|
+
pipe_id = pipe.id
|
50
|
+
|
51
|
+
for stage in pipe.stages:
|
52
|
+
if stage["displayName"] == "Development":
|
53
|
+
dev_stage = stage
|
54
|
+
else:
|
55
|
+
prod_stage = stage
|
56
|
+
|
57
|
+
stage = fcc.get_deployment_pipeline_stage(deployment_pipeline_id=pipe_id,
|
58
|
+
stage_id=dev_stage["id"])
|
59
|
+
self.assertIsNotNone(stage.id)
|
60
|
+
resp = fcc.assign_workspace_to_stage(deployment_pipeline_id=pipe_id,
|
61
|
+
stage_id=dev_stage["id"],
|
62
|
+
workspace_id=workspace_id)
|
63
|
+
self.assertEqual(resp, 200)
|
64
|
+
|
65
|
+
resp = fcc.assign_workspace_to_stage(deployment_pipeline_id=pipe_id,
|
66
|
+
stage_id=prod_stage["id"],
|
67
|
+
workspace_id=prod_workspace.id)
|
68
|
+
self.assertEqual(resp, 200)
|
69
|
+
principal = {
|
70
|
+
"id": user_id,
|
71
|
+
"type": "User"
|
72
|
+
}
|
73
|
+
|
74
|
+
resp = fcc.add_deployment_pipeline_role_assignment(deployment_pipeline_id=pipe_id,principal=principal, role="Admin")
|
75
|
+
self.assertEqual(resp, 200)
|
76
|
+
|
77
|
+
roles = fcc.list_deployment_pipeline_role_assignments(deployment_pipeline_id=pipe_id)
|
78
|
+
self.assertTrue(len(roles) == 2)
|
79
|
+
|
80
|
+
resp = fcc.delete_deployment_pipeline_role_assignment(deployment_pipeline_id=pipe_id, principal_id=user_id)
|
81
|
+
self.assertEqual(resp, 200)
|
82
|
+
|
83
|
+
roles = fcc.list_deployment_pipeline_role_assignments(deployment_pipeline_id=pipe_id)
|
84
|
+
self.assertTrue(len(roles) == 1)
|
85
|
+
|
86
|
+
pipes = fcc.list_deployment_pipelines(with_details=False)
|
87
|
+
sdk_pipes = [pipe for pipe in pipes if "sdk" in pipe["displayName"]]
|
88
|
+
self.assertTrue(len(sdk_pipes) > 0)
|
89
|
+
|
90
|
+
resp = fcc.deploy_stage_content(deployment_pipeline_id=pipe_id,
|
91
|
+
source_stage_id=dev_stage["id"],
|
92
|
+
target_stage_id=prod_stage["id"], wait_for_completion=False)
|
93
|
+
self.assertEqual(resp.status_code, 202)
|
94
|
+
|
95
|
+
ops = fcc.list_deployment_pipeline_operations(deployment_pipeline_id=pipe_id)
|
96
|
+
self.assertTrue(len(ops) > 0)
|
97
|
+
|
98
|
+
ops = fcc.get_deployment_pipeline_operation(deployment_pipeline_id=pipe_id, operation_id=ops[0]["id"])
|
99
|
+
self.assertIsNotNone(ops["id"])
|
100
|
+
|
101
|
+
stages = fcc.list_deployment_pipeline_stages(deployment_pipeline_id=pipe_id)
|
102
|
+
self.assertTrue(len(stages) == 2)
|
103
|
+
|
104
|
+
items = fcc.list_deployment_pipeline_stage_items(deployment_pipeline_id=pipe_id, stage_id=dev_stage["id"])
|
105
|
+
self.assertTrue(len(items) == 1)
|
106
|
+
|
107
|
+
updated_pipe = fcc.update_deployment_pipeline(deployment_pipeline_id=pipe.id, display_name="sdknewname", description="newdescription")
|
108
|
+
self.assertIsNotNone(updated_pipe.id)
|
109
|
+
|
110
|
+
pipe = fcc.get_deployment_pipeline(pipe_id)
|
111
|
+
self.assertIsNotNone(pipe.id)
|
112
|
+
self.assertTrue(pipe.display_name == "sdknewname")
|
113
|
+
|
114
|
+
updated_stage = fcc.update_deployment_pipeline_stage(deployment_pipeline_id=pipe_id, stage_id=prod_stage["id"],
|
115
|
+
display_name="newname", description="newdescription")
|
116
|
+
self.assertIsNotNone(updated_stage["id"])
|
117
|
+
|
118
|
+
stage = fcc.get_deployment_pipeline_stage(deployment_pipeline_id=pipe_id, stage_id=prod_stage["id"])
|
119
|
+
self.assertIsNotNone(stage.id)
|
120
|
+
self.assertTrue(stage.display_name == "newname")
|
121
|
+
|
122
|
+
for _ in range(10):
|
123
|
+
ops = fcc.get_deployment_pipeline_operation(deployment_pipeline_id=pipe_id, operation_id=ops["id"])
|
124
|
+
if ops["status"] != "Running":
|
125
|
+
break
|
126
|
+
else:
|
127
|
+
time.sleep(5)
|
128
|
+
|
129
|
+
resp = fcc.unassign_workspace_from_stage(deployment_pipeline_id=pipe_id,stage_id=prod_stage["id"])
|
130
|
+
self.assertEqual(resp, 200)
|
131
|
+
|
132
|
+
prod_workspace.delete()
|
133
|
+
|
134
|
+
resp = fcc.delete_deployment_pipeline(deployment_pipeline_id=pipe_id)
|
135
|
+
self.assertEqual(resp, 200)
|
@@ -0,0 +1,82 @@
|
|
1
|
+
|
2
|
+
# import unittest
|
3
|
+
# from dotenv import load_dotenv
|
4
|
+
# from msfabricpysdkcore import FabricClientCore
|
5
|
+
# from datetime import datetime
|
6
|
+
# from time import sleep
|
7
|
+
# load_dotenv()
|
8
|
+
|
9
|
+
# class TestFabricClientCore(unittest.TestCase):
|
10
|
+
|
11
|
+
# def __init__(self, *args, **kwargs):
|
12
|
+
# super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
13
|
+
|
14
|
+
# def test_eventstream_topology(self):
|
15
|
+
|
16
|
+
# fcc = FabricClientCore()
|
17
|
+
|
18
|
+
# workspace_id = "05bc5baa-ef02-4a31-ab20-158a478151d3"
|
19
|
+
|
20
|
+
# item_id = "94f4b54b-980b-43f9-8b67-ded8028cf1b9"
|
21
|
+
# custom_destination_id = "acd90d61-2792-4494-9f17-c822f2fb984d"
|
22
|
+
# custom_source_id = "9f382928-7d42-43f9-b02b-1b1352ad3ecd"
|
23
|
+
# source_id = "e58db369-e473-40f4-bedd-022b60540b17"
|
24
|
+
# destination_id = "2446e6cf-98c9-45cb-a102-78d2ca3eb257"
|
25
|
+
|
26
|
+
|
27
|
+
# topology = fcc.get_eventstream_topology(workspace_id, item_id)
|
28
|
+
# self.assertIsNotNone(topology)
|
29
|
+
# self.assertIn("sources", topology)
|
30
|
+
# self.assertIn("destinations", topology)
|
31
|
+
|
32
|
+
# destination = fcc.get_eventstream_destination(workspace_id, item_id, destination_id)
|
33
|
+
# self.assertIsNotNone(destination)
|
34
|
+
# self.assertEqual(destination["id"], destination_id)
|
35
|
+
|
36
|
+
# destination_conn = fcc.get_eventstream_destination_connection(workspace_id, item_id, custom_destination_id)
|
37
|
+
# self.assertIsNotNone(destination_conn)
|
38
|
+
# self.assertIn("fullyQualifiedNamespace", destination_conn)
|
39
|
+
|
40
|
+
# source = fcc.get_eventstream_source(workspace_id, item_id, source_id)
|
41
|
+
# self.assertIsNotNone(source)
|
42
|
+
# self.assertEqual(source["id"], source_id)
|
43
|
+
|
44
|
+
# source_conn = fcc.get_eventstream_source_connection(workspace_id, item_id, custom_source_id)
|
45
|
+
# self.assertIsNotNone(source_conn)
|
46
|
+
# self.assertIn("fullyQualifiedNamespace", source_conn)
|
47
|
+
|
48
|
+
# resp = fcc.pause_eventstream(workspace_id, item_id)
|
49
|
+
# self.assertEqual(resp, 200)
|
50
|
+
|
51
|
+
# def resume():
|
52
|
+
# resp = fcc.resume_eventstream(workspace_id, item_id, start_type="Now")
|
53
|
+
# self.assertEqual(resp, 200)
|
54
|
+
|
55
|
+
# for _ in range(12):
|
56
|
+
# try:
|
57
|
+
# resume()
|
58
|
+
# break
|
59
|
+
# except Exception as e:
|
60
|
+
# sleep(5)
|
61
|
+
|
62
|
+
# resp = fcc.pause_eventstream_source(workspace_id, item_id, source_id)
|
63
|
+
# self.assertEqual(resp, 200)
|
64
|
+
|
65
|
+
# resp = fcc.pause_eventstream_destination(workspace_id, item_id, destination_id)
|
66
|
+
# self.assertEqual(resp, 200)
|
67
|
+
|
68
|
+
# resp = fcc.resume_eventstream_source(workspace_id, item_id, source_id, start_type="Now")
|
69
|
+
# self.assertEqual(resp, 200)
|
70
|
+
|
71
|
+
# def resume():
|
72
|
+
# resp = fcc.resume_eventstream_destination(workspace_id, item_id, destination_id, start_type="Now")
|
73
|
+
# self.assertEqual(resp, 200)
|
74
|
+
|
75
|
+
# for _ in range(12):
|
76
|
+
# try:
|
77
|
+
# resume()
|
78
|
+
# break
|
79
|
+
# except Exception as e:
|
80
|
+
# sleep(5)
|
81
|
+
|
82
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import unittest
|
2
|
+
from dotenv import load_dotenv
|
3
|
+
from msfabricpysdkcore import FabricClientCore
|
4
|
+
|
5
|
+
load_dotenv()
|
6
|
+
|
7
|
+
class TestFabricClientCore(unittest.TestCase):
|
8
|
+
|
9
|
+
def __init__(self, *args, **kwargs):
|
10
|
+
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
11
|
+
self.fcc = FabricClientCore()
|
12
|
+
|
13
|
+
def test_folders(self):
|
14
|
+
fcc = self.fcc
|
15
|
+
|
16
|
+
workspace_id = "05bc5baa-ef02-4a31-ab20-158a478151d3"
|
17
|
+
folder_id = "d4f3a9fb-6975-4f5c-9c6b-ca205280966f"
|
18
|
+
|
19
|
+
folder = fcc.create_folder(workspace_id=workspace_id, display_name="sdk_sub_folder", parent_folder_id=folder_id)
|
20
|
+
self.assertIsNotNone(folder)
|
21
|
+
self.assertEqual(folder.display_name, "sdk_sub_folder")
|
22
|
+
|
23
|
+
folder_ = fcc.get_folder(workspace_id=workspace_id, folder_id=folder.id)
|
24
|
+
self.assertEqual(folder.id, folder_.id)
|
25
|
+
|
26
|
+
folders = fcc.list_folders(workspace_id=workspace_id)
|
27
|
+
folders = [folder for folder in folders if folder.display_name == "sdk_sub_folder"]
|
28
|
+
self.assertGreater(len(folders), 0)
|
29
|
+
|
30
|
+
folder = fcc.update_folder(workspace_id=workspace_id, folder_id=folder.id, display_name="sdk_sub_folder_updated")
|
31
|
+
self.assertEqual(folder.display_name, "sdk_sub_folder_updated")
|
32
|
+
|
33
|
+
folder = fcc.move_folder(workspace_id=workspace_id, folder_id=folder.id)
|
34
|
+
self.assertEqual(folder.display_name, "sdk_sub_folder_updated")
|
35
|
+
self.assertEqual(folder.parent_folder_id, "")
|
36
|
+
|
37
|
+
folders = fcc.list_folders(workspace_id=workspace_id)
|
38
|
+
|
39
|
+
for f in folders:
|
40
|
+
if f.display_name != "sdk_folder":
|
41
|
+
f.delete()
|
42
|
+
|
43
|
+
folders = fcc.list_folders(workspace_id=workspace_id)
|
44
|
+
self.assertEqual(len(folders), 1)
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import unittest
|
2
|
+
from dotenv import load_dotenv
|
3
|
+
from msfabricpysdkcore import FabricClientCore
|
4
|
+
|
5
|
+
load_dotenv()
|
6
|
+
|
7
|
+
class TestFabricClientCore(unittest.TestCase):
|
8
|
+
|
9
|
+
def __init__(self, *args, **kwargs):
|
10
|
+
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
11
|
+
self.fcc = FabricClientCore()
|
12
|
+
|
13
|
+
def test_tags(self):
|
14
|
+
fcc = self.fcc
|
15
|
+
|
16
|
+
tags = fcc.list_tags()
|
17
|
+
|
18
|
+
self.assertIsInstance(tags, list)
|
19
|
+
self.assertGreater(len(tags), 0)
|
20
|
+
sdk_tag = [tag for tag in tags if tag['displayName'] == 'sdk_tag'][0]
|
21
|
+
self.assertIsNotNone(sdk_tag)
|
22
|
+
|
23
|
+
resp = fcc.unapply_tags("05bc5baa-ef02-4a31-ab20-158a478151d3", "a9e59ec1-524b-49b1-a185-37e47dc0ceb9", [sdk_tag["id"]])
|
24
|
+
self.assertEqual(resp, 200)
|
25
|
+
resp = fcc.apply_tags("05bc5baa-ef02-4a31-ab20-158a478151d3", "a9e59ec1-524b-49b1-a185-37e47dc0ceb9", [sdk_tag["id"]])
|
26
|
+
self.assertEqual(resp, 200)
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
|
2
|
+
import unittest
|
3
|
+
from dotenv import load_dotenv
|
4
|
+
from msfabricpysdkcore import FabricClientCore
|
5
|
+
from datetime import datetime
|
6
|
+
load_dotenv()
|
7
|
+
|
8
|
+
class TestFabricClientCore(unittest.TestCase):
|
9
|
+
|
10
|
+
def __init__(self, *args, **kwargs):
|
11
|
+
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
12
|
+
self.fcc = FabricClientCore()
|
13
|
+
|
14
|
+
def test_variable_librarys(self):
|
15
|
+
fcc = self.fcc
|
16
|
+
|
17
|
+
workspace_id = "05bc5baa-ef02-4a31-ab20-158a478151d3"
|
18
|
+
item_id = "0812f094-1a5a-4b2a-aba2-e764af2709ec"
|
19
|
+
|
20
|
+
variable_librarys = fcc.list_variable_libraries(workspace_id=workspace_id)
|
21
|
+
for variable_library in variable_librarys:
|
22
|
+
if variable_library.id != item_id:
|
23
|
+
resp = fcc.delete_variable_library(workspace_id=workspace_id, variable_library_id=variable_library.id)
|
24
|
+
self.assertEqual(resp, 200)
|
25
|
+
|
26
|
+
variable_library_definition = fcc.get_variable_library_definition(workspace_id=workspace_id, variable_library_id=item_id)
|
27
|
+
self.assertIn("definition", variable_library_definition)
|
28
|
+
definition = variable_library_definition["definition"]
|
29
|
+
|
30
|
+
date_str = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
31
|
+
date_str = date_str.replace(" ", "T").replace(":", "").replace("-", "")
|
32
|
+
date_str = f"variablelibrary{date_str}"
|
33
|
+
|
34
|
+
variable_library_new = fcc.create_variable_library(workspace_id=workspace_id, display_name=date_str, definition=definition)
|
35
|
+
|
36
|
+
self.assertEqual(variable_library_new.display_name, date_str)
|
37
|
+
|
38
|
+
variable_library_get = fcc.get_variable_library(workspace_id=workspace_id, variable_library_id=variable_library_new.id)
|
39
|
+
self.assertEqual(variable_library_get.display_name, date_str)
|
40
|
+
|
41
|
+
variable_librarys = fcc.list_variable_libraries(workspace_id=workspace_id)
|
42
|
+
self.assertEqual(len(variable_librarys), 2)
|
43
|
+
|
44
|
+
date_str_updated = date_str + "_updated"
|
45
|
+
variable_library_updated = fcc.update_variable_library(workspace_id=workspace_id, variable_library_id=variable_library_new.id, display_name=date_str_updated, return_item=True)
|
46
|
+
self.assertEqual(variable_library_updated.display_name, date_str_updated)
|
47
|
+
|
48
|
+
variable_library_updated = fcc.update_variable_library_definition(workspace_id=workspace_id, variable_library_id=variable_library_new.id, definition=definition)
|
49
|
+
self.assertIn(variable_library_updated.status_code, [200, 202])
|
50
|
+
|
51
|
+
for variable_library in variable_librarys:
|
52
|
+
if variable_library.id != item_id:
|
53
|
+
resp = fcc.delete_variable_library(workspace_id=workspace_id, variable_library_id=variable_library.id)
|
54
|
+
self.assertEqual(resp, 200)
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|