honch-micropython 0.3.0__tar.gz → 0.3.1__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.
Files changed (19) hide show
  1. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/PKG-INFO +2 -2
  2. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/README.md +1 -1
  3. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/honch/__init__.py +1 -1
  4. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/honch/client.py +11 -0
  5. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/honch/config.py +1 -1
  6. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/honch_micropython.egg-info/PKG-INFO +2 -2
  7. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/pyproject.toml +1 -1
  8. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/tests/test_c_core_port_shape.py +3 -0
  9. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/tests/test_client_wrapper.py +13 -0
  10. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/honch/errors.py +0 -0
  11. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/honch/validation.py +0 -0
  12. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/honch_micropython.egg-info/SOURCES.txt +0 -0
  13. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/honch_micropython.egg-info/dependency_links.txt +0 -0
  14. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/honch_micropython.egg-info/top_level.txt +0 -0
  15. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/setup.cfg +0 -0
  16. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/tests/test_atomic_storage.py +0 -0
  17. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/tests/test_conformance.py +0 -0
  18. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/tests/test_sdk.py +0 -0
  19. {honch_micropython-0.3.0 → honch_micropython-0.3.1}/tests/test_unix_runtime_runner.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: honch-micropython
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Honch analytics SDK for MicroPython
5
5
  Author-email: Honch <support@honch.io>
6
6
  License: Apache-2.0
@@ -14,7 +14,7 @@ Stable MicroPython wrapper for the canonical Honch C core. The Python package ke
14
14
 
15
15
  ## Status
16
16
 
17
- Stable `0.3.0`. The SDK is not standalone pure Python; firmware must be built with the `_honch_core` user C module.
17
+ Stable `0.3.1`. The SDK is not standalone pure Python; firmware must be built with the `_honch_core` user C module.
18
18
 
19
19
  This port targets MicroPython. CircuitPython is not covered by the current user C module build flow.
20
20
 
@@ -4,7 +4,7 @@ Stable MicroPython wrapper for the canonical Honch C core. The Python package ke
4
4
 
5
5
  ## Status
6
6
 
7
- Stable `0.3.0`. The SDK is not standalone pure Python; firmware must be built with the `_honch_core` user C module.
7
+ Stable `0.3.1`. The SDK is not standalone pure Python; firmware must be built with the `_honch_core` user C module.
8
8
 
9
9
  This port targets MicroPython. CircuitPython is not covered by the current user C module build flow.
10
10
 
@@ -12,7 +12,7 @@ from .errors import (
12
12
  TransportError,
13
13
  )
14
14
 
15
- __version__ = "0.3.0"
15
+ __version__ = "0.3.1"
16
16
 
17
17
  __all__ = (
18
18
  "Honch",
@@ -110,6 +110,17 @@ class Honch:
110
110
  def queue_stats(self):
111
111
  return self._call("queue_stats")
112
112
 
113
+ def last_error(self):
114
+ """Structured detail for the most recent failure.
115
+
116
+ Returns a dict ``{status, reason, http, os_error, message, component}``
117
+ describing why the last operation failed -- e.g.
118
+ ``{'status': 'rejected', 'reason': 'auth_invalid_key', 'http': 401, ...}``
119
+ -- instead of a bare status code. ``status`` is ``'ok'`` and ``reason``
120
+ is ``'none'`` when nothing has failed yet.
121
+ """
122
+ return self._call("last_error")
123
+
113
124
  def track(self, event_name, properties=None):
114
125
  require_event_name(event_name)
115
126
  self._call("track", event_name, require_properties(properties))
@@ -1,7 +1,7 @@
1
1
  from .errors import InvalidArgumentError
2
2
 
3
3
 
4
- SDK_VERSION = "0.3.0"
4
+ SDK_VERSION = "0.3.1"
5
5
  SDK_PLATFORM = "micropython"
6
6
  DEFAULT_ENDPOINT_URL = "https://i.honch.io"
7
7
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: honch-micropython
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Honch analytics SDK for MicroPython
5
5
  Author-email: Honch <support@honch.io>
6
6
  License: Apache-2.0
@@ -14,7 +14,7 @@ Stable MicroPython wrapper for the canonical Honch C core. The Python package ke
14
14
 
15
15
  ## Status
16
16
 
17
- Stable `0.3.0`. The SDK is not standalone pure Python; firmware must be built with the `_honch_core` user C module.
17
+ Stable `0.3.1`. The SDK is not standalone pure Python; firmware must be built with the `_honch_core` user C module.
18
18
 
19
19
  This port targets MicroPython. CircuitPython is not covered by the current user C module build flow.
20
20
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "honch-micropython"
7
- version = "0.3.0"
7
+ version = "0.3.1"
8
8
  description = "Honch analytics SDK for MicroPython"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -189,6 +189,9 @@ class MicroPythonCCorePortShapeTests(unittest.TestCase):
189
189
  self.assertIn("honch_core_report_log_error", combined)
190
190
  self.assertNotIn("honch_core_report_error", combined)
191
191
  self.assertNotIn("capture_error", combined)
192
+ # Structured error context: last_error() returns http_status + reason.
193
+ self.assertIn("MP_QSTR_last_error", combined)
194
+ self.assertIn("honch_core_get_last_error", combined)
192
195
 
193
196
  def test_package_metadata_versions_match(self):
194
197
  init_py = self.read("ports/micropython/honch/__init__.py")
@@ -59,6 +59,16 @@ class FakeCoreClient:
59
59
  def queue_stats(self):
60
60
  return {"depth": 0}
61
61
 
62
+ def last_error(self):
63
+ return {
64
+ "status": "rejected",
65
+ "reason": "auth_invalid_key",
66
+ "http": 401,
67
+ "os_error": 0,
68
+ "message": "API key invalid or revoked",
69
+ "component": "http",
70
+ }
71
+
62
72
 
63
73
  class ClientWrapperTests(unittest.TestCase):
64
74
  def setUp(self):
@@ -141,6 +151,9 @@ class ClientWrapperTests(unittest.TestCase):
141
151
 
142
152
  self.assertEqual(client.get_device_id(), "device-from-core")
143
153
  self.assertEqual(client.queue_stats(), {"depth": 0})
154
+ last_error = client.last_error()
155
+ self.assertEqual(last_error["http"], 401)
156
+ self.assertEqual(last_error["reason"], "auth_invalid_key")
144
157
  self.assertEqual(client._core.config["api_key"], "key")
145
158
  self.assertEqual(client._core.config["device_id"], "device-1")
146
159
  self.assertEqual(client._core.config["batch_size"], 3)