Debian Codegraph @

tests/test_plugin_pingram.py

raw symbols SCIP
1 # BSD 2-Clause License
2 #
3 # Apprise - Push Notification Library.
4 # Copyright (c) 2026, Chris Caron <[email protected]>
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are met:
8 #
9 # 1. Redistributions of source code must retain the above copyright notice,
10 # this list of conditions and the following disclaimer.
11 #
12 # 2. Redistributions in binary form must reproduce the above copyright notice,
13 # this list of conditions and the following disclaimer in the documentation
14 # and/or other materials provided with the distribution.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 # POSSIBILITY OF SUCH DAMAGE.
27
28 from json import dumps, loads
29
30 # Disable logging for a cleaner testing output
31 import logging
32 from unittest import mock
33
34 from helpers import AppriseURLTester
35 import pytest
36 import requests
37
38 from apprise import Apprise, NotifyType
39 from apprise.plugins.pingram import NotifyPingram
40
41 logging.disable(logging.CRITICAL)
42
43 PINGRAM_GOOD_RESPONSE = dumps({"trackingId": "abc123"})
44
45 PINGRAM_BAD_RESPONSE = "{"
46
47 # Our Testing URLs
48 apprise_url_tests = (
49 (
50 "pingram://",
51 {
52 # No API Key at all
53 "instance": TypeError,
54 },
55 ),
56 (
57 "pingram://:@/",
58 {
59 "instance": TypeError,
60 },
61 ),
62 (
63 "pingram://abcd",
64 {
65 # Doesn't match the pingram_(sk|pk)_ prefix
66 "instance": TypeError,
67 },
68 ),
69 (
70 "pingram://pingram_sk_key/+15551235553/?mode=invalid",
71 {
72 # Invalid mode
73 "instance": TypeError,
74 },
75 ),
76 (
77 "pingram://pingram_sk_key/+15551235553/?region=invalid",
78 {
79 # Invalid region
80 "instance": TypeError,
81 },
82 ),
83 (
84 "pingram://pingram_sk_key/+15551235553/?type=*(",
85 {
86 # Invalid type
87 "instance": TypeError,
88 },
89 ),
90 (
91 "pingram://pingram_sk_key/+15551235553/?channels=bad",
92 {
93 # Invalid channel
94 "instance": TypeError,
95 },
96 ),
97 (
98 "pingram://pingram_sk_abc123/g@rb@ge/+15551235553/",
99 {
100 # g@rb@ge entry ignored (invalid target, dropped with a
101 # warning, preserved for round-trip only)
102 "instance": NotifyPingram,
103 "requests_response_text": PINGRAM_GOOD_RESPONSE,
104 },
105 ),
106 (
107 "pingram://pingram_sk_abc123/g@rb@ge/",
108 {
109 # Only an invalid target specified; nothing to notify
110 "instance": NotifyPingram,
111 "requests_response_text": PINGRAM_GOOD_RESPONSE,
112 "notify_response": False,
113 },
114 ),
115 (
116 "pingram://pingram_sk_abc123/[email protected]/[email protected]",
117 {
118 # Two emails back to back with no id between them each
119 # become their own recipient
120 "instance": NotifyPingram,
121 "requests_response_text": PINGRAM_GOOD_RESPONSE,
122 },
123 ),
124 (
125 "pingram://pingram_sk_abc123/+15551235553",
126 {
127 # A bare phone number with no id is valid
128 "instance": NotifyPingram,
129 "requests_response_text": PINGRAM_GOOD_RESPONSE,
130 },
131 ),
132 (
133 "pingram://pingram_pk_abc123/[email protected]",
134 {
135 # A bare email with no id is valid; public key prefix works
136 "instance": NotifyPingram,
137 "requests_response_text": PINGRAM_GOOD_RESPONSE,
138 },
139 ),
140 (
141 "pingram://pingram_sk_abc123/+15551235553/+15551235554",
142 {
143 # Multiple id-less phone numbers become separate targets
144 "instance": NotifyPingram,
145 "requests_response_text": PINGRAM_GOOD_RESPONSE,
146 },
147 ),
148 (
149 "pingram://pingram_sk_abc123/id/+15551235553",
150 {
151 # An id can still optionally be supplied
152 "instance": NotifyPingram,
153 "requests_response_text": PINGRAM_GOOD_RESPONSE,
154 },
155 ),
156 (
157 "pingram://pingram_sk_abc123/id/id2/[email protected]",
158 {
159 # two ids in a row; first is dropped in favor of the second
160 "instance": NotifyPingram,
161 "requests_response_text": PINGRAM_GOOD_RESPONSE,
162 },
163 ),
164 (
165 (
166 "pingram://type@pingram_sk_abc123/id10/[email protected]/"
167 "id5/+15551235555/id8/+15551235534"
168 "?reply=Chris<[email protected]>"
169 ),
170 {
171 "instance": NotifyPingram,
172 "requests_response_text": PINGRAM_GOOD_RESPONSE,
173 },
174 ),
175 (
176 (
177 "pingram://type@pingram_sk_abc123/abc1/[email protected]/"
178 "id5/+15551235555/?from=Chris&reply=Christopher"
179 ),
180 {
181 "instance": NotifyPingram,
182 "requests_response_text": PINGRAM_GOOD_RESPONSE,
183 },
184 ),
185 (
186 (
187 "pingram://type@pingram_sk_abc123/[email protected]/"
188 "[email protected]&[email protected]"
189 ),
190 {
191 # Set from/source
192 "instance": NotifyPingram,
193 "requests_response_text": PINGRAM_GOOD_RESPONSE,
194 },
195 ),
196 (
197 (
198 "pingram://type@pingram_sk_abc123/[email protected]/"
199 "[email protected]&[email protected]&[email protected]"
200 ),
201 {
202 "instance": NotifyPingram,
203 "requests_response_text": PINGRAM_GOOD_RESPONSE,
204 # Our expected url(privacy=True) startswith() response:
205 "privacy_url": "pingram://[email protected]/",
206 },
207 ),
208 (
209 "pingram://?apikey=pingram_sk_abc123&to=id,[email protected]"
210 "&type=typec",
211 {
212 # use just kwargs
213 "instance": NotifyPingram,
214 "requests_response_text": PINGRAM_GOOD_RESPONSE,
215 "privacy_url": "pingram://[email protected]/",
216 },
217 ),
218 (
219 "pingram://pingram_sk_abc123?to=id,[email protected]&type=typeb",
220 {
221 # apikey is pulled from the host
222 "instance": NotifyPingram,
223 "requests_response_text": PINGRAM_GOOD_RESPONSE,
224 "privacy_url": "pingram://[email protected]/",
225 },
226 ),
227 (
228 "pingram://?apikey=pingram_sk_abc123&type=test-type&region=eu",
229 {
230 # No targets specified
231 "instance": NotifyPingram,
232 "requests_response_text": PINGRAM_GOOD_RESPONSE,
233 "notify_response": False,
234 },
235 ),
236 (
237 "pingram://?apikey=pingram_sk_abc123&to=id,[email protected]"
238 "&type=typec",
239 {
240 # bad response
241 "instance": NotifyPingram,
242 "requests_response_text": PINGRAM_BAD_RESPONSE,
243 "notify_response": False,
244 },
245 ),
246 (
247 "pingram://pingram_sk_abc123/id/[email protected]?bcc=invalid",
248 {
249 # A good email with a bad Blind Carbon Copy
250 "instance": NotifyPingram,
251 "requests_response_text": PINGRAM_GOOD_RESPONSE,
252 },
253 ),
254 (
255 "pingram://pingram_sk_abc123/id/[email protected][email protected]",
256 {
257 # A good email with Carbon Copy
258 "instance": NotifyPingram,
259 "requests_response_text": PINGRAM_GOOD_RESPONSE,
260 },
261 ),
262 (
263 "pingram://pingram_sk_abc123/id/[email protected]"
264 "?channels=email,sms,slack,mobile_push,web_push,inapp,call",
265 {
266 # All channels forced at once
267 "instance": NotifyPingram,
268 "requests_response_text": PINGRAM_GOOD_RESPONSE,
269 },
270 ),
271 (
272 "pingram://pingram_sk_abc123/id/[email protected]"
273 "?cc=Chris<[email protected]>",
274 {
275 "instance": NotifyPingram,
276 "requests_response_text": PINGRAM_GOOD_RESPONSE,
277 },
278 ),
279 (
280 "pingram://pingram_sk_abc123/id/[email protected]?cc=invalid",
281 {
282 "instance": NotifyPingram,
283 "requests_response_text": PINGRAM_GOOD_RESPONSE,
284 },
285 ),
286 (
287 "pingram://pingram_sk_abc123/id/[email protected]?to=invalid",
288 {
289 # an invalid to email
290 "instance": NotifyPingram,
291 "requests_response_text": PINGRAM_GOOD_RESPONSE,
292 },
293 ),
294 (
295 "pingram://pingram_sk_abc123/id1/[email protected]"
296 "?to=id,Chris<[email protected]>",
297 {
298 "instance": NotifyPingram,
299 "requests_response_text": PINGRAM_GOOD_RESPONSE,
300 },
301 ),
302 (
303 "pingram://pingram_sk_abc123/id2/[email protected]/"
304 "id/[email protected]/id/[email protected]/id/+15552341234"
305 "?:token=value",
306 {
307 # Several targets to notify
308 "instance": NotifyPingram,
309 "requests_response_text": PINGRAM_GOOD_RESPONSE,
310 },
311 ),
312 (
313 "pingram://pingram_sk_abc123/id/[email protected]"
314 "?bcc=Chris<[email protected]>",
315 {
316 "instance": NotifyPingram,
317 "requests_response_text": PINGRAM_GOOD_RESPONSE,
318 },
319 ),
320 (
321 "pingram://pingram_sk_abc123/id/[email protected]"
322 "?:sub=value&:sub2=value2",
323 {
324 # A good email with template substitutions
325 "instance": NotifyPingram,
326 "requests_response_text": PINGRAM_GOOD_RESPONSE,
327 "privacy_url": "pingram://p...3/",
328 },
329 ),
330 (
331 "pingram://pingram_sk_abc123/id/[email protected]",
332 {
333 "instance": NotifyPingram,
334 # force a failure
335 "response": False,
336 "requests_response_code": requests.codes.internal_server_error,
337 "requests_response_text": PINGRAM_GOOD_RESPONSE,
338 },
339 ),
340 (
341 "pingram://pingram_sk_abc123/id/[email protected]",
342 {
343 "instance": NotifyPingram,
344 # throw a bizarre code forcing us to fail to look it up
345 "response": False,
346 "requests_response_code": 999,
347 "requests_response_text": PINGRAM_GOOD_RESPONSE,
348 },
349 ),
350 (
351 "pingram://pingram_sk_abc123/id/[email protected]",
352 {
353 "instance": NotifyPingram,
354 # Throws connection and transfer exceptions when this
355 # flag is set and tests that we gracefully handle them
356 "test_requests_exceptions": True,
357 "requests_response_text": PINGRAM_GOOD_RESPONSE,
358 },
359 ),
360 )
361
362
363 def test_plugin_pingram_urls():
364 """NotifyPingram() Apprise URLs."""
365
366 # Run our general tests
367 AppriseURLTester(tests=apprise_url_tests).run_all()
368
369
370 @mock.patch("requests.post")
371 def test_plugin_pingram_template_sms_payloads(mock_post):
372 """NotifyPingram() Testing Template SMS Payloads."""
373
374 okay_response = requests.Request()
375 okay_response.status_code = requests.codes.ok
376 okay_response.content = PINGRAM_GOOD_RESPONSE
377
378 # Assign our mock object our return value
379 mock_post.return_value = okay_response
380
381 # Details
382 apikey = "pingram_sk_my_key"
383 message_type = "apprise-post"
384 targets = "userid/+1-555-123-4567"
385
386 obj = Apprise.instantiate(
387 f"pingram://{message_type}@{apikey}/{targets}?mode=template"
388 )
389 assert isinstance(obj, NotifyPingram)
390 assert isinstance(obj.url(), str)
391
392 # No calls made yet
393 assert mock_post.call_count == 0
394
395 # Send our notification
396 assert (
397 obj.notify(body="body", title="title", notify_type=NotifyType.INFO)
398 is True
399 )
400
401 # delivery of message
402 assert mock_post.call_count == 1
403 assert mock_post.call_args_list[0][0][0] == "https://api.pingram.io/send"
404
405 payload = loads(mock_post.call_args_list[0][1]["data"])
406 assert payload == {
407 "type": "apprise-post",
408 "to": {
409 "id": "userid",
410 "number": "+15551234567",
411 },
412 "parameters": {
413 "appBody": "body",
414 "appTitle": "title",
415 "appType": "info",
416 "appId": "Apprise",
417 "appDescription": "Apprise Notifications",
418 "appColor": "#3AA3E3",
419 "appImageUrl": (
420 "https://github.com/caronc/apprise/raw/master/apprise"
421 "/assets/themes/default/apprise-info-72x72.png"
422 ),
423 "appUrl": "https://github.com/caronc/apprise",
424 },
425 }
426 headers = mock_post.call_args_list[0][1]["headers"]
427 assert headers == {
428 "User-Agent": "Apprise",
429 "Content-Type": "application/json",
430 "Authorization": f"Bearer {apikey}",
431 }
432
433 # Reset our mock object
434 mock_post.reset_mock()
435
436
437 @mock.patch("requests.post")
438 def test_plugin_pingram_template_email_payloads(mock_post):
439 """NotifyPingram() Testing Template Email Payloads."""
440
441 okay_response = requests.Request()
442 okay_response.status_code = requests.codes.ok
443 okay_response.content = PINGRAM_GOOD_RESPONSE
444
445 # Assign our mock object our return value
446 mock_post.return_value = okay_response
447
448 # Details
449 apikey = "pingram_sk_my_key_abc"
450 message_type = "apprise-post"
451 targets = "userid/[email protected]"
452
453 obj = Apprise.instantiate(
454 f"pingram://{message_type}@{apikey}/{targets}"
455 f"?from=Chris<[email protected]>&[email protected]&"
456 f"[email protected]&:customToken=customValue&mode=template"
457 )
458 assert isinstance(obj, NotifyPingram)
459 assert isinstance(obj.url(), str)
460
461 # No calls made yet
462 assert mock_post.call_count == 0
463
464 # Send our notification
465 assert (
466 obj.notify(body="body", title="title", notify_type=NotifyType.INFO)
467 is True
468 )
469
470 # delivery of message
471 assert mock_post.call_count == 1
472 assert mock_post.call_args_list[0][0][0] == "https://api.pingram.io/send"
473
474 payload = loads(mock_post.call_args_list[0][1]["data"])
475 assert payload == {
476 "type": "apprise-post",
477 "to": {
478 "id": "userid",
479 "email": "[email protected]",
480 },
481 "options": {
482 "email": {
483 "fromAddress": "[email protected]",
484 "fromName": "Chris",
485 "ccAddresses": ["[email protected]"],
486 "bccAddresses": ["[email protected]"],
487 }
488 },
489 "parameters": {
490 "customToken": "customValue",
491 "appBody": "body",
492 "appTitle": "title",
493 "appType": "info",
494 "appId": "Apprise",
495 "appDescription": "Apprise Notifications",
496 "appColor": "#3AA3E3",
497 "appImageUrl": (
498 "https://github.com/caronc/apprise/raw/master/apprise/"
499 "assets/themes/default/apprise-info-72x72.png"
500 ),
501 "appUrl": "https://github.com/caronc/apprise",
502 },
503 }
504 headers = mock_post.call_args_list[0][1]["headers"]
505 assert headers == {
506 "User-Agent": "Apprise",
507 "Content-Type": "application/json",
508 "Authorization": f"Bearer {apikey}",
509 }
510
511 # Reset our mock object
512 mock_post.reset_mock()
513
514
515 @mock.patch("requests.post")
516 def test_plugin_pingram_message_payloads(mock_post):
517 """NotifyPingram() Testing Message Payloads."""
518
519 okay_response = requests.Request()
520 okay_response.status_code = requests.codes.ok
521 okay_response.content = PINGRAM_GOOD_RESPONSE
522
523 # Assign our mock object our return value
524 mock_post.return_value = okay_response
525
526 # Details
527 apikey = "pingram_sk_my_key_abc"
528 message_type = "apprise-post"
529 targets = "userid/[email protected]/+15551239876"
530
531 obj = Apprise.instantiate(
532 f"pingram://{message_type}@{apikey}/{targets}"
533 f"?from=Chris<[email protected]>&[email protected]"
534 f"&mode=message"
535 )
536 assert isinstance(obj, NotifyPingram)
537 assert isinstance(obj.url(), str)
538
539 # Send our notification
540 assert (
541 obj.notify(body="body", title="title", notify_type=NotifyType.INFO)
542 is True
543 )
544
545 # delivery of message
546 assert mock_post.call_count == 1
547 assert mock_post.call_args_list[0][0][0] == "https://api.pingram.io/send"
548
549 payload = loads(mock_post.call_args_list[0][1]["data"])
550 assert payload == {
551 "type": "apprise-post",
552 "to": {
553 "id": "userid",
554 "email": "[email protected]",
555 "number": "+15551239876",
556 },
557 "email": {
558 "subject": "title",
559 "html": "body",
560 "senderName": "Chris",
561 "senderEmail": "[email protected]",
562 },
563 "options": {
564 "email": {
565 "fromAddress": "[email protected]",
566 "fromName": "Chris",
567 "bccAddresses": ["[email protected]"],
568 },
569 },
570 }
571 headers = mock_post.call_args_list[0][1]["headers"]
572 assert headers == {
573 "User-Agent": "Apprise",
574 "Content-Type": "application/json",
575 "Authorization": f"Bearer {apikey}",
576 }
577
578 # Reset our mock object
579 mock_post.reset_mock()
580
581 # Reversing the sms with email causes auto-detection channel to
582 # be sms instead of email
583 targets = "userid/+15551239876/[email protected]"
584
585 obj = Apprise.instantiate(
586 f"pingram://{apikey}/{targets}"
587 f"?from=Chris<[email protected]>&[email protected]"
588 )
589 assert isinstance(obj, NotifyPingram)
590 assert isinstance(obj.url(), str)
591
592 # Send our notification
593 assert (
594 obj.notify(body="body", title="title", notify_type=NotifyType.INFO)
595 is True
596 )
597
598 # delivery of message
599 assert mock_post.call_count == 1
600 assert mock_post.call_args_list[0][0][0] == "https://api.pingram.io/send"
601
602 payload = loads(mock_post.call_args_list[0][1]["data"])
603 assert payload == {
604 "type": "apprise",
605 "to": {
606 "id": "userid",
607 "number": "+15551239876",
608 "email": "[email protected]",
609 },
610 "sms": {"message": "title\nbody"},
611 "options": {
612 "email": {
613 "fromAddress": "[email protected]",
614 "fromName": "Chris",
615 "bccAddresses": ["[email protected]"],
616 },
617 },
618 }
619
620 headers = mock_post.call_args_list[0][1]["headers"]
621 assert headers == {
622 "User-Agent": "Apprise",
623 "Content-Type": "application/json",
624 "Authorization": f"Bearer {apikey}",
625 }
626
627 # Reset our mock object
628 mock_post.reset_mock()
629
630 # Experiment with fixed channels (including the call/TTS channel)
631 obj = Apprise.instantiate(
632 f"pingram://{message_type}@{apikey}/{targets}"
633 f"?from=Chris<[email protected]>&[email protected]"
634 f"&mode=message&channels=sms,slack,call"
635 )
636 assert isinstance(obj, NotifyPingram)
637 assert isinstance(obj.url(), str)
638
639 # Send our notification
640 assert (
641 obj.notify(body="body", title="title", notify_type=NotifyType.INFO)
642 is True
643 )
644
645 # delivery of message
646 assert mock_post.call_count == 1
647 assert mock_post.call_args_list[0][0][0] == "https://api.pingram.io/send"
648
649 payload = loads(mock_post.call_args_list[0][1]["data"])
650 assert payload == {
651 "type": "apprise-post",
652 "to": {
653 "id": "userid",
654 "email": "[email protected]",
655 "number": "+15551239876",
656 },
657 "slack": {"text": "title\nbody"},
658 "sms": {"message": "title\nbody"},
659 "call": {"message": "title\nbody"},
660 "options": {
661 "email": {
662 "fromAddress": "[email protected]",
663 "fromName": "Chris",
664 "bccAddresses": ["[email protected]"],
665 },
666 },
667 }
668
669 headers = mock_post.call_args_list[0][1]["headers"]
670 assert headers == {
671 "User-Agent": "Apprise",
672 "Content-Type": "application/json",
673 "Authorization": f"Bearer {apikey}",
674 }
675
676
677 @mock.patch("requests.post")
678 def test_plugin_pingram_targets(mock_post):
679 """NotifyPingram() Testing Target Parsing."""
680
681 okay_response = requests.Request()
682 okay_response.status_code = requests.codes.ok
683 okay_response.content = PINGRAM_GOOD_RESPONSE
684
685 # Assign our mock object our return value
686 mock_post.return_value = okay_response
687
688 apikey = "pingram_sk_abc123"
689
690 # A bare phone number with no id is valid
691 obj = Apprise.instantiate(f"pingram://{apikey}/+15551234567")
692 assert isinstance(obj, NotifyPingram)
693 assert isinstance(obj.url(), str)
694
695 assert (
696 obj.notify(body="body", title="title", notify_type=NotifyType.INFO)
697 is True
698 )
699
700 assert mock_post.call_count == 1
701 assert mock_post.call_args_list[0][0][0] == "https://api.pingram.io/send"
702
703 # No "id" present since none was supplied in the URL
704 payload = loads(mock_post.call_args_list[0][1]["data"])
705 assert payload == {
706 "type": "apprise",
707 "to": {
708 "number": "+15551234567",
709 },
710 "sms": {"message": "title\nbody"},
711 }
712
713 headers = mock_post.call_args_list[0][1]["headers"]
714 assert headers == {
715 "User-Agent": "Apprise",
716 "Content-Type": "application/json",
717 "Authorization": f"Bearer {apikey}",
718 }
719
720 mock_post.reset_mock()
721
722 # Multiple id-less phone targets each become their own recipient
723 obj = Apprise.instantiate(f"pingram://{apikey}/+15551234567/+15551234568")
724 assert isinstance(obj, NotifyPingram)
725 assert len(obj.targets) == 2
726
727 assert (
728 obj.notify(body="body", title="title", notify_type=NotifyType.INFO)
729 is True
730 )
731 assert mock_post.call_count == 2
732
733 mock_post.reset_mock()
734
735 # Region support carries over to the Pingram endpoints too
736 obj = Apprise.instantiate(f"pingram://{apikey}/+15551234567?region=eu")
737 assert isinstance(obj, NotifyPingram)
738 assert (
739 obj.notify(body="body", title="title", notify_type=NotifyType.INFO)
740 is True
741 )
742 assert mock_post.call_count == 1
743 assert (
744 mock_post.call_args_list[0][0][0] == "https://api.eu.pingram.io/send"
745 )
746
747 mock_post.reset_mock()
748
749 # An id can still optionally be supplied alongside the number
750 obj = Apprise.instantiate(f"pingram://{apikey}/myid/+15551234567")
751 assert isinstance(obj, NotifyPingram)
752 assert (
753 obj.notify(body="body", title="title", notify_type=NotifyType.INFO)
754 is True
755 )
756 payload = loads(mock_post.call_args_list[0][1]["data"])
757 assert payload["to"] == {"id": "myid", "number": "+15551234567"}
758
759
760 def test_plugin_pingram_edge_cases():
761 """NotifyPingram() Edge Cases."""
762
763 # No API Key raises TypeError
764 with pytest.raises(TypeError):
765 NotifyPingram(apikey=None, targets=["+15551239876"])
766
767 # An invalid API Key (wrong prefix) raises TypeError
768 with pytest.raises(TypeError):
769 NotifyPingram(apikey="not-a-pingram-key", targets=["+15551239876"])
770
771 # Tests case where tokens is == None
772 obj = NotifyPingram(apikey="pingram_sk_my_key", targets=["+15551239876"])
773 assert isinstance(obj, NotifyPingram)
774 assert isinstance(obj.url(), str)
775 assert obj.tokens == {}