MCPcopy
hub / github.com/spaceandtimefdn/SxT-Python-SDK / test_call_api

Function test_call_api

tests/test_sxtbaseapi.py:82–113  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80
81
82def test_call_api():
83 sxtb = SXTBaseAPI(access_token)
84 success, user_exists = sxtb.call_api('auth/idexists/{id}', auth_header=False,
85 request_type=sxtb.APICALLTYPE.GET,
86 path_parms={'id':userid})
87 assert success
88 assert user_exists
89
90 success, user_exists = sxtb.call_api('auth/idexists/{id}', auth_header=False,
91 request_type=sxtb.APICALLTYPE.GET,
92 path_parms={'id':'this_user_should_not_exist_please_dont_create'})
93 assert success
94 assert not user_exists
95
96 success, data = sxtb.call_api('sql', auth_header=True, request_type=sxtb.APICALLTYPE.POST,
97 data_parms={'sqlText':'select * from sxtlabs.singularity'} )
98 assert success
99 assert data[0]['NAME'] == 'Singularity' # hopefully this doesn't change...
100
101 # what happens if we break it?
102 # bad API
103 success, data = sxtb.call_api('no_such_api', auth_header=False, request_type=sxtb.APICALLTYPE.POST)
104 assert not success
105 assert data['status_code'] == 555
106
107 # good API, not validated
108 success, data = sxtb.call_api('sql', auth_header=False, request_type=sxtb.APICALLTYPE.POST,
109 data_parms={'sqlText':'select * from sxtlabs.singularity'} )
110 assert not success
111 assert data['status_code'] == 401
112 assert 'Unauthorized' in data['error']
113 assert 'JWT authorization failed' in data['text']
114
115
116def test_logout():

Callers 1

test_sxtbaseapi.pyFile · 0.85

Calls 2

call_apiMethod · 0.95
SXTBaseAPIClass · 0.90

Tested by

no test coverage detected