Testing Remedy-on-Demand REST API code I am writing a python module to interact to the ROD (remedy on demand) BMC ticketing product. So far I have only written the log in and log out methods and tests. Before I crack on with the more complex methods I hope someone can review the current test strategy and happy to hear any suggestions for improvements.
rodAPI.py
import requests


class RodApi:
    def __init__(self, fqdn, username, password, token_type=&quot;AR-JWT&quot;):
        self.username = username
        self.password = password
        self.fqdn = fqdn
        self.token_type = token_type
        self.login_url = f&quot;https://{fqdn}/api/jwt/login&quot;
        self.logout_url = f&quot;https://{fqdn}/api/jwt/logout&quot;
        self.token = None

    def login(self) -&gt; bool:
        data = {&quot;username&quot;: self.username, &quot;password&quot;: self.password}
        headers = {&quot;content-type&quot;: &quot;application/x-www-form-urlencoded&quot;}
        response = requests.post(self.login_url, data=data, headers=headers)

        print(f&quot;connecting to URL: {self.login_url}&quot;)
        print(f&quot;https status code: {response.status_code}&quot;)
        self.token = response.text
        if response.status_code == 200:
            return True
        return False

    def logout(self) -&gt; bool:
        headers = {&quot;Authorization&quot;: f&quot;{self.token_type} {self.token}&quot;}
        response = requests.post(self.logout_url, headers=headers)

        print(f&quot;connecting to URL: {self.logout_url}&quot;)
        print(f&quot;https status code: {response.status_code}&quot;)
        if response.status_code == 204:
            print(f&quot;Logged out with a status of: {response.status_code}&quot;)
            return True
        else:
            print(f&quot;Error logging out: {response.text}&quot;)
            return False

test_rodAPI
import pytest

from rodAPI import RodApi


@pytest.fixture()
def rod_api_instance():
    rod_api = RodApi(&quot;example.com&quot;, &quot;some_user&quot;, &quot;some_password&quot;)
    return rod_api


@pytest.fixture()
def rod_api_logged_in_instance(responses, rod_api_instance):
    responses.add(responses.POST, rod_api_instance.login_url, body=&quot;some_token_string&quot;)
    rod_api_instance.login()
    return rod_api_instance


def test_login_success(responses, rod_api_instance: RodApi):
    responses.add(responses.POST, rod_api_instance.login_url, body=&quot;some_token_string&quot;)
    result = rod_api_instance.login()
    assert result is True
    assert rod_api_instance.token == &quot;some_token_string&quot;


def test_login_fail(responses, rod_api_instance: RodApi):
    responses.add(responses.POST, rod_api_instance.login_url, status=404)
    result = rod_api_instance.login()
    assert result is False


def test_logout_success(responses, rod_api_logged_in_instance: RodApi):
    responses.add(responses.POST, rod_api_logged_in_instance.logout_url, status=204)
    result = rod_api_logged_in_instance.logout()
    assert result is True


def test_logout_fail(responses, rod_api_logged_in_instance: RodApi):
    responses.add(responses.POST, rod_api_logged_in_instance.logout_url, status=404)
    result = rod_api_logged_in_instance.logout()
    assert result is False
```
Redundant headers
Read
https://github.com/psf/requests/blob/master/requests/models.py#L514 - your use of
    headers = {&quot;content-type&quot;: &quot;application/x-www-form-urlencoded&quot;}

should not be needed.
Out-of-order progress
You print
    print(f&quot;connecting to URL: {self.login_url}&quot;)

when this has already happened. Either say &quot;connected to&quot;, or move this statement before your post.
Exception degradation
Resist the urge to sabotage the Python exception system. Rather than returning booleans from your methods, call response.raise_for_status, and optionally wrap that in a try/except/raise MyException() from e with your own exception type. raise_for_status will also obviate your status code checks.