MCPcopy
hub / github.com/caronc/apprise / test_notify_base

Function test_notify_base

tests/test_notify_base.py:42–281  ·  view source on GitHub ↗

API: NotifyBase() object

()

Source from the content-addressed store, hash-verified

40
41
42def test_notify_base():
43 """
44 API: NotifyBase() object
45
46 """
47
48 # invalid types throw exceptions
49 with pytest.raises(TypeError):
50 NotifyBase(**{"format": "invalid"})
51
52 # invalid types throw exceptions
53 with pytest.raises(TypeError):
54 NotifyBase(**{"overflow": "invalid"})
55
56 # Bad port information
57 nb = NotifyBase(port="invalid")
58 assert nb.port is None
59
60 nb = NotifyBase(port=10)
61 assert nb.port == 10
62
63 assert isinstance(nb.url(), str)
64 assert str(nb) == nb.url()
65
66 with pytest.raises(NotImplementedError):
67 # Each sub-module is that inherits this as a parent is required to
68 # over-ride this function. So direct calls to this throws a not
69 # implemented error intentionally
70 nb.send("test message")
71
72 # Throttle overrides..
73 nb = NotifyBase()
74 nb.request_rate_per_sec = 0.0
75 start_time = default_timer()
76 nb.throttle()
77 elapsed = default_timer() - start_time
78 # Should be a very fast response time since we set it to zero but we'll
79 # check for less then 500 to be fair as some testing systems may be slower
80 # then other
81 assert elapsed < 0.5
82
83 # Concurrent calls should achieve the same response
84 start_time = default_timer()
85 nb.throttle()
86 elapsed = default_timer() - start_time
87 assert elapsed < 0.5
88
89 nb = NotifyBase()
90 nb.request_rate_per_sec = 1.0
91
92 # Set our time to now
93 start_time = default_timer()
94 nb.throttle()
95 elapsed = default_timer() - start_time
96 # A first call to throttle (Without telling it a time previously ran) does
97 # not block for any length of time; it just merely sets us up for
98 # concurrent calls to block
99 assert elapsed < 0.5

Callers

nothing calls this directly

Calls 15

sendMethod · 0.95
image_urlMethod · 0.95
image_pathMethod · 0.95
image_rawMethod · 0.95
colorMethod · 0.95
asciiMethod · 0.95
NotifyBaseClass · 0.90
throttleMethod · 0.80
escape_htmlMethod · 0.80
split_pathMethod · 0.80
parse_listMethod · 0.80
parse_phone_noMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…