()
| 80 | |
| 81 | |
| 82 | def 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 | |
| 116 | def test_logout(): |
no test coverage detected