Skip to content

Commit dd67ace

Browse files
committed
add deprecated pulsar endpoints
1 parent 31a803c commit dd67ace

2 files changed

Lines changed: 105 additions & 29 deletions

File tree

‎ns1/rest/pulsar_decisions.py‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#
44
# License under The MIT License (MIT). See LICENSE in project root.
55
#
6+
import warnings
7+
68
from . import resource
79

810
try:
@@ -134,6 +136,17 @@ def get_filters_time(self, callback=None, errback=None, **kwargs):
134136
def get_decision_customer(
135137
self, customer_id, callback=None, errback=None, **kwargs
136138
):
139+
"""
140+
.. deprecated::
141+
The ``pulsar/query/decision/customer`` API is deprecated and will
142+
be removed in a future release.
143+
"""
144+
warnings.warn(
145+
"Decisions.get_decision_customer is deprecated and will be"
146+
" removed in a future release.",
147+
DeprecationWarning,
148+
stacklevel=2,
149+
)
137150
path = self._make_query_url(
138151
"decision/customer/%s" % customer_id, **kwargs
139152
)
@@ -147,6 +160,17 @@ def get_decision_customer(
147160
def get_decision_customer_undetermined(
148161
self, customer_id, callback=None, errback=None, **kwargs
149162
):
163+
"""
164+
.. deprecated::
165+
The ``pulsar/query/decision/customer`` API is deprecated and will
166+
be removed in a future release.
167+
"""
168+
warnings.warn(
169+
"Decisions.get_decision_customer_undetermined is deprecated and"
170+
" will be removed in a future release.",
171+
DeprecationWarning,
172+
stacklevel=2,
173+
)
150174
path = self._make_query_url(
151175
"decision/customer/%s/undetermined" % customer_id, **kwargs
152176
)
@@ -166,6 +190,17 @@ def get_decision_record(
166190
errback=None,
167191
**kwargs
168192
):
193+
"""
194+
.. deprecated::
195+
The ``pulsar/query/decision/customer`` API is deprecated and will
196+
be removed in a future release.
197+
"""
198+
warnings.warn(
199+
"Decisions.get_decision_record is deprecated and will be"
200+
" removed in a future release.",
201+
DeprecationWarning,
202+
stacklevel=2,
203+
)
169204
path = self._make_query_url(
170205
"decision/customer/%s/record/%s/%s"
171206
% (customer_id, domain, rec_type),
@@ -187,6 +222,17 @@ def get_decision_record_undetermined(
187222
errback=None,
188223
**kwargs
189224
):
225+
"""
226+
.. deprecated::
227+
The ``pulsar/query/decision/customer`` API is deprecated and will
228+
be removed in a future release.
229+
"""
230+
warnings.warn(
231+
"Decisions.get_decision_record_undetermined is deprecated and"
232+
" will be removed in a future release.",
233+
DeprecationWarning,
234+
stacklevel=2,
235+
)
190236
path = self._make_query_url(
191237
"decision/customer/%s/record/%s/%s/undetermined"
192238
% (customer_id, domain, rec_type),
@@ -202,6 +248,17 @@ def get_decision_record_undetermined(
202248
def get_decision_total(
203249
self, customer_id, callback=None, errback=None, **kwargs
204250
):
251+
"""
252+
.. deprecated::
253+
The ``pulsar/query/decision/customer`` API is deprecated and will
254+
be removed in a future release.
255+
"""
256+
warnings.warn(
257+
"Decisions.get_decision_total is deprecated and will be"
258+
" removed in a future release.",
259+
DeprecationWarning,
260+
stacklevel=2,
261+
)
205262
path = self._make_query_url(
206263
"decision/customer/%s/total" % customer_id, **kwargs
207264
)

‎tests/unit/test_pulsar_decisions.py‎

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,48 @@ def pulsar_decisions_config(config):
9797
"pulsar/query/decisions/filters/time",
9898
{"callback": None, "errback": None},
9999
),
100+
(
101+
"get_decisions_records",
102+
None,
103+
"GET",
104+
"pulsar/query/decisions/records",
105+
{"callback": None, "errback": None},
106+
),
107+
(
108+
"get_decisions_results_record",
109+
None,
110+
"GET",
111+
"pulsar/query/decisions/results/record",
112+
{"callback": None, "errback": None},
113+
),
114+
],
115+
)
116+
def test_rest_pulsar_decisions(
117+
pulsar_decisions_config, op, args, method, url, kwargs
118+
):
119+
"""Test Pulsar Decisions REST API endpoints."""
120+
m = ns1.rest.pulsar_decisions.Decisions(pulsar_decisions_config)
121+
m._make_request = mock.MagicMock()
122+
operation = getattr(m, op)
123+
if args is not None:
124+
if (
125+
isinstance(args, list)
126+
and len(args) == 1
127+
and isinstance(args[0], dict)
128+
):
129+
# Handle kwargs case
130+
operation(**args[0])
131+
else:
132+
# Handle positional args case
133+
operation(*args)
134+
else:
135+
operation()
136+
m._make_request.assert_called_once_with(method, url, **kwargs)
137+
138+
139+
@pytest.mark.parametrize(
140+
"op, args, method, url, kwargs",
141+
[
100142
(
101143
"get_decision_customer",
102144
["12345"],
@@ -132,45 +174,22 @@ def pulsar_decisions_config(config):
132174
"pulsar/query/decision/customer/12345/total",
133175
{"callback": None, "errback": None},
134176
),
135-
(
136-
"get_decisions_records",
137-
None,
138-
"GET",
139-
"pulsar/query/decisions/records",
140-
{"callback": None, "errback": None},
141-
),
142-
(
143-
"get_decisions_results_record",
144-
None,
145-
"GET",
146-
"pulsar/query/decisions/results/record",
147-
{"callback": None, "errback": None},
148-
),
149177
],
150178
)
151-
def test_rest_pulsar_decisions(
179+
def test_rest_pulsar_decisions_deprecated(
152180
pulsar_decisions_config, op, args, method, url, kwargs
153181
):
154-
"""Test Pulsar Decisions REST API endpoints."""
182+
"""Test deprecated pulsar/query/decision/customer endpoints."""
155183
m = ns1.rest.pulsar_decisions.Decisions(pulsar_decisions_config)
156184
m._make_request = mock.MagicMock()
157185
operation = getattr(m, op)
158-
if args is not None:
159-
if (
160-
isinstance(args, list)
161-
and len(args) == 1
162-
and isinstance(args[0], dict)
163-
):
164-
# Handle kwargs case
165-
operation(**args[0])
166-
else:
167-
# Handle positional args case
168-
operation(*args)
169-
else:
170-
operation()
186+
with pytest.warns(DeprecationWarning):
187+
operation(*args)
171188
m._make_request.assert_called_once_with(method, url, **kwargs)
172189

173190

191+
192+
174193
def test_rest_pulsar_decisions_build_query_params(pulsar_decisions_config):
175194
"""Test _build_query_params helper method."""
176195
m = ns1.rest.pulsar_decisions.Decisions(pulsar_decisions_config)

0 commit comments

Comments
 (0)