39 lines
874 B
Python
39 lines
874 B
Python
"""
|
|
Caller tests
|
|
"""
|
|
|
|
from corelibs_dump_data.dump_data import dump_data
|
|
from corelibs.requests_handling.caller import Caller, ErrorResponse
|
|
from corelibs.requests_handling.auth_helpers import basic_auth
|
|
|
|
|
|
def test_basic_auth():
|
|
"""basic auth test"""
|
|
user = "user"
|
|
password = "pass"
|
|
auth_header = basic_auth(user, password)
|
|
print(f"Auth Header for '{user}' & '{password}': {auth_header}")
|
|
|
|
|
|
def test_caller():
|
|
"""Caller tests"""
|
|
caller = Caller()
|
|
response = caller.get("https://httpbin.org/get")
|
|
if isinstance(response, ErrorResponse):
|
|
print(f"Error: {response.message}")
|
|
else:
|
|
print(f"Response Status Code: {response.status_code}")
|
|
print(f"Response Content: {dump_data(response.json())}")
|
|
|
|
|
|
def main():
|
|
"""main"""
|
|
test_caller()
|
|
test_basic_auth()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|
|
# __END__
|