stinger-python-utils 0.1.6__tar.gz → 0.1.7__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.4
2
2
  Name: stinger-python-utils
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: Common utilities for Stinger Python services.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "stinger-python-utils"
7
- version = "0.1.6"
7
+ version = "0.1.7"
8
8
  description = "Common utilities for Stinger Python services."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -14,6 +14,7 @@ class MessageCreator:
14
14
  payload=payload.model_dump_json(by_alias=True).encode("utf-8"),
15
15
  qos=1,
16
16
  retain=False,
17
+ content_type="application/json",
17
18
  )
18
19
 
19
20
  @classmethod
@@ -26,6 +27,7 @@ class MessageCreator:
26
27
  qos=1,
27
28
  retain=True,
28
29
  message_expiry_interval=expiry_seconds,
30
+ content_type="application/json",
29
31
  )
30
32
 
31
33
  @classmethod
@@ -55,6 +57,7 @@ class MessageCreator:
55
57
  else correlation_id
56
58
  ),
57
59
  user_properties={"ReturnCode": str(rc)},
60
+ content_type="application/json",
58
61
  )
59
62
  if (
60
63
  debug_info is not None and msg_obj.user_properties is not None
@@ -95,6 +98,7 @@ class MessageCreator:
95
98
  else correlation_id
96
99
  ),
97
100
  user_properties={"ReturnCode": str(rc)},
101
+ content_type="application/json",
98
102
  )
99
103
  return msg_obj
100
104
 
@@ -133,6 +137,7 @@ class MessageCreator:
133
137
  payload=property_obj.model_dump_json(by_alias=True).encode("utf-8"),
134
138
  qos=1,
135
139
  retain=False,
140
+ content_type="application/json",
136
141
  response_topic=response_topic,
137
142
  correlation_data=(
138
143
  correlation_id.encode("utf-8")
@@ -166,6 +171,7 @@ class MessageCreator:
166
171
  payload=property_obj.model_dump_json(by_alias=True).encode("utf-8"),
167
172
  qos=1,
168
173
  retain=False,
174
+ content_type="application/json",
169
175
  correlation_data=(
170
176
  correlation_id.encode("utf-8")
171
177
  if isinstance(correlation_id, str)
@@ -198,6 +204,7 @@ class MessageCreator:
198
204
  qos=1,
199
205
  retain=False,
200
206
  response_topic=response_topic,
207
+ content_type="application/json",
201
208
  correlation_data=(
202
209
  correlation_id.encode("utf-8")
203
210
  if isinstance(correlation_id, str)
@@ -20,6 +20,7 @@ class TestSignalMessage:
20
20
  assert message.qos == 1
21
21
  assert message.retain is False
22
22
  assert b'"name":"test"' in message.payload
23
+ assert message.content_type == "application/json"
23
24
 
24
25
 
25
26
  class TestStatusMessage:
@@ -32,6 +33,7 @@ class TestStatusMessage:
32
33
  assert message.qos == 1
33
34
  assert message.retain is True
34
35
  assert message.message_expiry_interval == 3600
36
+ assert message.content_type == "application/json"
35
37
 
36
38
 
37
39
  class TestErrorResponseMessage:
@@ -48,6 +50,7 @@ class TestErrorResponseMessage:
48
50
  assert message.retain is False
49
51
  assert message.user_properties["ReturnCode"] == "500"
50
52
  assert message.correlation_data == b"abc-123"
53
+ assert message.content_type == "application/json"
51
54
 
52
55
  def test_error_response_with_bytes_correlation_id(self):
53
56
  """Test error response with bytes correlation ID"""
@@ -59,6 +62,7 @@ class TestErrorResponseMessage:
59
62
 
60
63
  assert message.correlation_data == b"xyz-789"
61
64
  assert message.user_properties["ReturnCode"] == "400"
65
+ assert message.content_type == "application/json"
62
66
 
63
67
  def test_error_response_with_debug_info(self):
64
68
  """Test error response includes debug info"""
@@ -69,6 +73,7 @@ class TestErrorResponseMessage:
69
73
  )
70
74
 
71
75
  assert message.user_properties["DebugInfo"] == "Something went wrong"
76
+ assert message.content_type == "application/json"
72
77
 
73
78
 
74
79
  class TestResponseMessage:
@@ -86,6 +91,7 @@ class TestResponseMessage:
86
91
  assert message.qos == 1
87
92
  assert message.user_properties["ReturnCode"] == "200"
88
93
  assert message.correlation_data == b"req-123"
94
+ assert message.content_type == "application/json"
89
95
 
90
96
  def test_response_message_with_string(self):
91
97
  """Test response message with string payload"""
@@ -96,6 +102,7 @@ class TestResponseMessage:
96
102
  )
97
103
 
98
104
  assert message.payload == b"success"
105
+ assert message.content_type == "application/json"
99
106
 
100
107
  def test_response_message_with_bytes(self):
101
108
  """Test response message with bytes payload"""
@@ -106,6 +113,7 @@ class TestResponseMessage:
106
113
  )
107
114
 
108
115
  assert message.payload == b"binary data"
116
+ assert message.content_type == "application/json"
109
117
 
110
118
 
111
119
  class TestPropertyStateMessage:
@@ -147,6 +155,7 @@ class TestPropertyUpdateRequestMessage:
147
155
  assert message.response_topic == "property/response"
148
156
  assert message.user_properties["PropertyVersion"] == "1.0"
149
157
  assert message.correlation_data == b"update-123"
158
+ assert message.content_type == "application/json"
150
159
 
151
160
 
152
161
  class TestPropertyResponseMessage:
@@ -165,6 +174,7 @@ class TestPropertyResponseMessage:
165
174
  assert message.user_properties["ReturnCode"] == "200"
166
175
  assert message.user_properties["PropertyVersion"] == "1.0"
167
176
  assert message.correlation_data == b"update-123"
177
+ assert message.content_type == "application/json"
168
178
 
169
179
  def test_property_response_message_with_debug_info(self):
170
180
  """Test property response message with debug info"""
@@ -178,6 +188,7 @@ class TestPropertyResponseMessage:
178
188
  )
179
189
 
180
190
  assert message.user_properties["DebugInfo"] == "Update failed"
191
+ assert message.content_type == "application/json"
181
192
 
182
193
 
183
194
  class TestRequestMessage:
@@ -194,6 +205,7 @@ class TestRequestMessage:
194
205
  assert message.response_topic == "response/topic"
195
206
  assert message.correlation_data is not None
196
207
  assert len(message.correlation_data) > 0
208
+ assert message.content_type == "application/json"
197
209
 
198
210
  def test_request_message_with_correlation_id(self):
199
211
  """Test request message with provided correlation ID"""
@@ -206,3 +218,4 @@ class TestRequestMessage:
206
218
  )
207
219
 
208
220
  assert message.correlation_data == b"req-456"
221
+ assert message.content_type == "application/json"
@@ -1272,7 +1272,7 @@ wheels = [
1272
1272
 
1273
1273
  [[package]]
1274
1274
  name = "stinger-python-utils"
1275
- version = "0.1.6"
1275
+ version = "0.1.7"
1276
1276
  source = { editable = "." }
1277
1277
  dependencies = [
1278
1278
  { name = "pydantic", version = "2.5.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.8'" },