forked from factset/analyticsapi-engines-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_components_api.py
More file actions
96 lines (81 loc) · 4.92 KB
/
test_components_api.py
File metadata and controls
96 lines (81 loc) · 4.92 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import unittest
from fds.analyticsapi.engines.api.components_api import ComponentsApi
from fds.analyticsapi.engines.model.component_summary import ComponentSummary
from fds.analyticsapi.engines.model.pa_component import PAComponent
from fds.analyticsapi.engines.model.pa_component_root import PAComponentRoot
from fds.analyticsapi.engines.model.component_summary_root import ComponentSummaryRoot
from fds.analyticsapi.engines.model.vault_component import VaultComponent
import common_parameters
from common_functions import CommonFunctions
class TestComponentsApi(unittest.TestCase):
def setUp(self):
self.components_api = ComponentsApi(CommonFunctions.build_api_client())
######################################################################################
# PA Components Test Cases
######################################################################################
def test_get_all_pa_components(self):
response = self.components_api.get_pa_components(
document=common_parameters.pa_default_document,
_return_http_data_only=False
)
component_id = list(response[0]['data'].keys())[0]
self.assertEqual(response[1], 200, "Response should be 200 - Success")
self.assertEqual(
type(response[0]), ComponentSummaryRoot, "Response should be of dictionary type")
self.assertEqual(type(response[0]['data'][component_id]),
ComponentSummary, "Response should be of ComponentSummary type")
# This test encounters ApiTypeException due to response having fields set to null instead of being hidden
@unittest.skip("Skip until fix API behavior where null property is returned instead of hidden")
def test_get_pa_component_by_id(self):
components = self.components_api.get_pa_components(
document=common_parameters.pa_default_document)
component_id = list(components['data'].keys())[0]
response = self.components_api.get_pa_component_by_id(
id=component_id, _return_http_data_only=False)
self.assertEqual(response[1], 200, "Response should be 200 - Success")
self.assertEqual(type(
response[0]), PAComponentRoot, "Response should be of PAComponentRoot type.")
self.assertEqual(type(response[0]['data'][component_id]),
ComponentSummary, "Response should be of ComponentSummary type")
######################################################################################
# Vault Components Test Cases
######################################################################################
def test_get_all_vault_components(self):
response = self.components_api.get_vault_components(
document=common_parameters.vault_default_document,
_return_http_data_only=False
)
component_id = list(response[0]['data'].keys())[0]
self.assertEqual(response[1], 200, "Response should be 200 - Success")
self.assertEqual(
type(response[0]), ComponentSummaryRoot, "Response should be of dictionary type")
self.assertEqual(type(response[0]['data'][component_id]),
ComponentSummary, "Response should be of ComponentSummary type")
# This test encounters ApiTypeException due to response having fields set to null instead of being hidden
@unittest.skip("Skip until fix API behavior where null property is returned instead of hidden")
def test_get_vault_component_by_id(self):
components = self.components_api.get_vault_components(
document=common_parameters.vault_default_document)
component_id = list(components['data'].keys())[0]
response = self.components_api.get_vault_component_by_id(
component_id, _return_http_data_only=False)
component_id = list(response[0]['data'].keys())[0]
self.assertEqual(response[1], 200, "Response should be 200 - Success")
self.assertEqual(type(response[0]['data']), VaultComponent,
"Response should be of VaultComponent type.")
######################################################################################
# Spar Components Test Cases
######################################################################################
def test_get_all_spar_components(self):
response = self.components_api.get_spar_components(
document=common_parameters.spar_default_document,
_return_http_data_only=False
)
component_id = list(response[0]['data'].keys())[0]
self.assertEqual(response[1], 200, "Response should be 200 - Success")
self.assertEqual(
type(response[0]), ComponentSummaryRoot, "Response should be of dictionary type")
self.assertEqual(type(response[0]['data'][component_id]),
ComponentSummary, "Response should be of ComponentSummary type")
if __name__ == '__main__':
unittest.main()