petsafe-api 3.0.3__tar.gz → 3.0.4__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.
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/PKG-INFO +1 -1
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/petsafe/devices.py +7 -4
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/petsafe_api.egg-info/PKG-INFO +1 -1
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/petsafe_api.egg-info/SOURCES.txt +2 -1
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/setup.py +1 -1
- petsafe_api-3.0.4/tests/test_smartfeed_last_feeding.py +34 -0
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/LICENSE +0 -0
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/README.md +0 -0
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/petsafe/__init__.py +0 -0
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/petsafe/__main__.py +0 -0
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/petsafe/client.py +0 -0
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/petsafe/const.py +0 -0
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/petsafe/general.py +0 -0
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/petsafe/pets.py +0 -0
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/petsafe_api.egg-info/dependency_links.txt +0 -0
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/petsafe_api.egg-info/requires.txt +0 -0
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/petsafe_api.egg-info/top_level.txt +0 -0
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/setup.cfg +0 -0
- {petsafe_api-3.0.3 → petsafe_api-3.0.4}/tests/test_smartdoor_modes.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: petsafe-api
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.4
|
|
4
4
|
Summary: Provides ability to connect and control a PetSafe Smart Feed, Scoopfree, and Smart Door devices using the PetSafe API.
|
|
5
5
|
Home-page: https://github.com/ThomasHFWright/petsafe-api
|
|
6
6
|
Author: Jordan Stremming & Dominick Meglio & Thomas Wright
|
|
@@ -83,10 +83,13 @@ class DeviceSmartFeed:
|
|
|
83
83
|
|
|
84
84
|
"""
|
|
85
85
|
messages = await self.get_messages_since()
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
feed_done = [
|
|
87
|
+
message for message in messages
|
|
88
|
+
if message.get("message_type") == "FEED_DONE"
|
|
89
|
+
and isinstance(message.get("payload"), dict)
|
|
90
|
+
and isinstance(message["payload"].get("time"), int)
|
|
91
|
+
]
|
|
92
|
+
return max(feed_done, key=lambda message: message["payload"]["time"], default=None)
|
|
90
93
|
|
|
91
94
|
async def feed(
|
|
92
95
|
self, amount: int = 1, slow_feed: bool = None, update_data: bool = True
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: petsafe-api
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.4
|
|
4
4
|
Summary: Provides ability to connect and control a PetSafe Smart Feed, Scoopfree, and Smart Door devices using the PetSafe API.
|
|
5
5
|
Home-page: https://github.com/ThomasHFWright/petsafe-api
|
|
6
6
|
Author: Jordan Stremming & Dominick Meglio & Thomas Wright
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Regression check for unordered SmartFeed messages."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
from itertools import permutations
|
|
5
|
+
from unittest.mock import AsyncMock
|
|
6
|
+
|
|
7
|
+
from petsafe.devices import DeviceSmartFeed
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_last_feeding_uses_latest_valid_timestamp():
|
|
11
|
+
async def check():
|
|
12
|
+
feeder = DeviceSmartFeed(None, {})
|
|
13
|
+
oldest = {"message_type": "FEED_DONE", "payload": {"time": 100, "amount": 1}}
|
|
14
|
+
middle = {"message_type": "FEED_DONE", "payload": {"time": 200, "amount": 2}}
|
|
15
|
+
newest = {"message_type": "FEED_DONE", "payload": {"time": 300, "amount": 3}}
|
|
16
|
+
invalid = [
|
|
17
|
+
{},
|
|
18
|
+
{"message_type": "FEED_START", "payload": {"time": 400}},
|
|
19
|
+
{"message_type": "FEED_DONE"},
|
|
20
|
+
{"message_type": "FEED_DONE", "payload": None},
|
|
21
|
+
{"message_type": "FEED_DONE", "payload": []},
|
|
22
|
+
{"message_type": "FEED_DONE", "payload": {}},
|
|
23
|
+
{"message_type": "FEED_DONE", "payload": {"time": "400"}},
|
|
24
|
+
]
|
|
25
|
+
for order in permutations((oldest, middle, newest)):
|
|
26
|
+
messages = invalid + list(order)
|
|
27
|
+
feeder.get_messages_since = AsyncMock(return_value=messages)
|
|
28
|
+
assert await feeder.get_last_feeding() is newest
|
|
29
|
+
assert messages == invalid + list(order)
|
|
30
|
+
for messages, expected in (([], None), (invalid, None), ([oldest], oldest)):
|
|
31
|
+
feeder.get_messages_since = AsyncMock(return_value=messages)
|
|
32
|
+
assert await feeder.get_last_feeding() is expected
|
|
33
|
+
|
|
34
|
+
asyncio.run(check())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|