Skip to content

Commit d0d1c49

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents ede1ff1 + 361c110 commit d0d1c49

File tree

14 files changed

+378
-329
lines changed

14 files changed

+378
-329
lines changed

docs/testing/unittest.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ api
4040
___
4141

4242
Classes inherited from :py:class:`~mailpit.testing.unittest.EMailTestCase` will connect to the Mailpit-API automatically on creation.
43-
They will provide you with the :py:attr:`~mailpit.testing.unittest.EmailTestCase.api` attribute, which is an instance of :py:class:`~mailpit.client.api.API`:
43+
They will provide you with the :py:attr:`~mailpit.testing.unittest.EmailTestCase.mailpit_api` attribute, which is an instance of :py:class:`~mailpit.client.api.API`:
4444

4545
.. code-block:: python
4646

mailpit/client/api.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""module containing API related"""
2-
import logging as _logging
2+
import logging
33
from typing import Optional, List, Any
44

5-
import httpx as _httpx
5+
import httpx
66

7-
import mailpit.client.models as _models
7+
import mailpit.client.models as models
88

9-
_log = _logging.getLogger("mailpit_client")
9+
_log = logging.getLogger("mailpit_client")
1010

1111

1212
class API:
@@ -22,9 +22,9 @@ class representing the different endpoints of the API
2222
def __init__(self, mailpit_url: str, timeout: Optional[int] = None):
2323
self.mailpit_url = mailpit_url
2424
self.timeout = timeout
25-
self.last_response: Optional[_httpx.Response] = None
25+
self.last_response: Optional[httpx.Response] = None
2626

27-
def get_messages(self, limit: int = 50, start: int = 0) -> _models.Messages:
27+
def get_messages(self, limit: int = 50, start: int = 0) -> models.Messages:
2828
"""
2929
send a GET request in order to retrieve messages
3030
@@ -35,15 +35,15 @@ def get_messages(self, limit: int = 50, start: int = 0) -> _models.Messages:
3535

3636
# pylint: disable = no-member
3737

38-
response = _httpx.get(
38+
response = httpx.get(
3939
f"{self.mailpit_url}/{API.MESSAGES_ENDPOINT}",
4040
params={"limit": limit, "start": start},
4141
timeout=self.timeout,
4242
)
4343
self.last_response = response
4444
response.raise_for_status()
4545
_log.debug(response.text)
46-
return _models.Messages.from_json(response.text) # type: ignore
46+
return models.Messages.from_json(response.text) # type: ignore
4747

4848
def delete_messages(self, ids: List[str]):
4949
"""
@@ -52,7 +52,7 @@ def delete_messages(self, ids: List[str]):
5252
:param ids: the IDs of the messages to delete;
5353
NOTE: passing an empty list will delete *all* messages
5454
"""
55-
response = _httpx.request(
55+
response = httpx.request(
5656
method="DELETE",
5757
url=f"{self.mailpit_url}/{API.MESSAGES_ENDPOINT}",
5858
data={"ids": ids},
@@ -70,15 +70,15 @@ def put_messages(self, ids: List[str], key: str, value: Any):
7070
:param key: the message's attribute to update
7171
:param value: the value to update the attribute with
7272
"""
73-
response = _httpx.put(
73+
response = httpx.put(
7474
f"{self.mailpit_url}/{API.MESSAGES_ENDPOINT}",
7575
data={"ids": ids, key: value},
7676
timeout=self.timeout,
7777
)
7878
self.last_response = response
7979
response.raise_for_status()
8080

81-
def get_message(self, message_id: str) -> _models.Message:
81+
def get_message(self, message_id: str) -> models.Message:
8282
"""
8383
Send a GET request to get a certain Message by its Message-ID
8484
@@ -87,14 +87,14 @@ def get_message(self, message_id: str) -> _models.Message:
8787

8888
# pylint: disable = no-member
8989

90-
response = _httpx.get(
90+
response = httpx.get(
9191
f"{self.mailpit_url}/{API.MESSAGE_ENDPOINT}/{message_id}",
9292
timeout=self.timeout,
9393
)
9494
self.last_response = response
9595
response.raise_for_status()
9696
_log.debug(response.text)
97-
message = _models.Message.from_json(response.text)
97+
message = models.Message.from_json(response.text)
9898
return message
9999

100100
def get_message_attachment(self, message_id: str, part_id: str) -> str:
@@ -106,24 +106,24 @@ def get_message_attachment(self, message_id: str, part_id: str) -> str:
106106
:param part_id: the Part-ID of the attachment to receive
107107
:return the attachment's data
108108
"""
109-
response = _httpx.get(
109+
response = httpx.get(
110110
f"{self.mailpit_url}/{API.MESSAGE_ENDPOINT}/{message_id}/part/{part_id}",
111111
timeout=self.timeout,
112112
)
113113
self.last_response = response
114114
response.raise_for_status()
115115
return response.text
116116

117-
def get_message_headers(self, message_id: str) -> _models.Headers:
117+
def get_message_headers(self, message_id: str) -> models.Headers:
118118
"""
119119
Send a GET request to get a message's Headers
120120
121121
:param message_id: The Message-ID to get the headers for
122122
"""
123-
response = _httpx.get(
123+
response = httpx.get(
124124
f"{self.mailpit_url}/{API.MESSAGE_ENDPOINT}/{message_id}/headers",
125125
timeout=self.timeout,
126126
)
127127
self.last_response = response
128128
response.raise_for_status()
129-
return _models.Headers.from_json(response.text) # type: ignore
129+
return models.Headers.from_json(response.text) # type: ignore

0 commit comments

Comments
 (0)