Move requests handling to corelibs_requests module
This commit is contained in:
38
test-run/requests_handling/caller.py
Normal file
38
test-run/requests_handling/caller.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""
|
||||
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__
|
||||
Reference in New Issue
Block a user