python-ntfy 0.3.8__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-ntfy
3
- Version: 0.3.8
3
+ Version: 0.4.0
4
4
  Summary: An ntfy library aiming for feature completeness
5
5
  Home-page: https://github.com/MatthewCane/python-ntfy
6
6
  License: MIT
@@ -55,6 +55,7 @@ See the full documentation site at [https://matthewcane.github.io/python-ntfy/](
55
55
  - Custom servers
56
56
  - Sending plaintext messages
57
57
  - Sending Markdown formatted text messages
58
+ - Scheduling messages
58
59
  - Retrieving cached messages
59
60
  - Scheduled delivery
60
61
  - Tags
@@ -92,10 +93,8 @@ These tools are also run in the CI pipeline and must pass before merging.
92
93
 
93
94
  This project is aiming for 95% code coverage. Any added features must include comprihensive tests.
94
95
 
95
- #### Setup Steps
96
+ #### Testing Steps
96
97
 
97
- 1. Start the test docker container with `docker-compose -f tests/assets/test_containers.yml up`
98
- 2. Run the tests with `poetry run pytest --cov`
99
-
100
- The tests will sent messages to the `python_ntfy_testing` topic so you will need to view the web interface and subcribe to that topic to see the test messages.
98
+ 1. Make sure you have `docker` and `docker-compose` installed
99
+ 2. Run the tests with `poetry run pytest --cov` or use the VSCode testing extension
101
100
 
@@ -35,6 +35,7 @@ See the full documentation site at [https://matthewcane.github.io/python-ntfy/](
35
35
  - Custom servers
36
36
  - Sending plaintext messages
37
37
  - Sending Markdown formatted text messages
38
+ - Scheduling messages
38
39
  - Retrieving cached messages
39
40
  - Scheduled delivery
40
41
  - Tags
@@ -72,9 +73,7 @@ These tools are also run in the CI pipeline and must pass before merging.
72
73
 
73
74
  This project is aiming for 95% code coverage. Any added features must include comprihensive tests.
74
75
 
75
- #### Setup Steps
76
+ #### Testing Steps
76
77
 
77
- 1. Start the test docker container with `docker-compose -f tests/assets/test_containers.yml up`
78
- 2. Run the tests with `poetry run pytest --cov`
79
-
80
- The tests will sent messages to the `python_ntfy_testing` topic so you will need to view the web interface and subcribe to that topic to see the test messages.
78
+ 1. Make sure you have `docker` and `docker-compose` installed
79
+ 2. Run the tests with `poetry run pytest --cov` or use the VSCode testing extension
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-ntfy"
3
- version = "0.3.8"
3
+ version = "0.4.0"
4
4
  description = "An ntfy library aiming for feature completeness"
5
5
  authors = ["Matthew Cane <matthew.cane0@gmail.com>"]
6
6
  readme = "README.md"
@@ -74,3 +74,6 @@ ignore = [
74
74
 
75
75
  [tool.ruff.lint.pydocstyle]
76
76
  convention = "google"
77
+
78
+ [tool.pytest.ini_options]
79
+ asyncio_default_fixture_loop_scope = "function"
@@ -1,4 +1,5 @@
1
1
  import json
2
+ from datetime import datetime
2
3
  from enum import Enum
3
4
  from pathlib import Path
4
5
  from typing import Optional, Union
@@ -133,6 +134,7 @@ def send(
133
134
  priority: MessagePriority = MessagePriority.DEFAULT,
134
135
  tags: Optional[list] = None,
135
136
  actions: Optional[list[Union[ViewAction, BroadcastAction, HttpAction]]] = None,
137
+ schedule: Optional[datetime] = None,
136
138
  format_as_markdown: bool = False,
137
139
  timeout_seconds: int = 5,
138
140
  ) -> dict:
@@ -147,9 +149,10 @@ def send(
147
149
  priority: The priority of the message.
148
150
  tags: A list of tags to attach to the message. Can be an emoji short code.
149
151
  actions: A list of Actions objects to attach to the message.
152
+ schedule: The time to schedule the message to be sent.
150
153
  format_as_markdown: If true, the message will be formatted as markdown.
151
154
  additional_topics: A list of additional topics to send the message to.
152
- timeout_seconds: The number of seconds to wait before timing out.
155
+ timeout_seconds: The number of seconds to wait before timing out the reqest to the server.
153
156
 
154
157
  Returns:
155
158
  dict: The response from the server.
@@ -176,6 +179,9 @@ def send(
176
179
  if len(actions) > 0:
177
180
  headers["Actions"] = " ; ".join([action.to_header() for action in actions])
178
181
 
182
+ if schedule:
183
+ headers["Delay"] = str(int(schedule.timestamp()))
184
+
179
185
  return json.loads(
180
186
  requests.post(
181
187
  url=self.url,
@@ -194,6 +200,7 @@ def send_file(
194
200
  priority: MessagePriority = MessagePriority.DEFAULT,
195
201
  tags: Optional[list] = None,
196
202
  actions: Optional[list[Union[ViewAction, BroadcastAction, HttpAction]]] = None,
203
+ schedule: Optional[datetime] = None,
197
204
  timeout_seconds: int = 30,
198
205
  ) -> dict:
199
206
  """Sends a file to the server.
@@ -204,6 +211,7 @@ def send_file(
204
211
  priority: The priority of the message. Optional, defaults to MessagePriority.
205
212
  tags: A list of tags to attach to the message. Can be an emoji short code.
206
213
  actions: A list of ActionButton objects to attach to the message.
214
+ schedule: The time to schedule the message to be sent. Must be more than 10 seconds away and less than 3 days in the future.
207
215
  timeout_seconds: The number of seconds to wait before timing out.
208
216
 
209
217
  Returns:
@@ -228,6 +236,9 @@ def send_file(
228
236
  "Actions": " ; ".join([action.to_header() for action in actions]),
229
237
  }
230
238
 
239
+ if schedule:
240
+ headers["Delay"] = str(int(schedule.timestamp()))
241
+
231
242
  with Path(file).open("rb") as f:
232
243
  return json.loads(
233
244
  requests.post(
File without changes