Debian Codegraph @

tests/test_plugin_jellyfin.py

raw
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 # Disable logging for a cleaner testing output
29 import logging
30
31 from helpers import AppriseURLTester
32
33 from apprise import Apprise
34 from apprise.exception import AppriseImproperlyConfigured
35 from apprise.plugins import jellyfin
36
37 logging.disable(logging.CRITICAL)
38
39 # Our Testing URLs
40 # Note: The majority of tests are already handled by the emby:// adaptation
41
42 apprise_url_tests = (
43 # Insecure Request; no hostname specified
44 (
45 "jellyfin://",
46 {
47 "instance": None,
48 },
49 ),
50 # Secure Request; no hostname specified
51 (
52 "jellyfins://",
53 {
54 "instance": None,
55 },
56 ),
57 # No user specified
58 (
59 "jellyfin://localhost",
60 {
61 # Missing a username
62 "instance": AppriseImproperlyConfigured,
63 },
64 ),
65 (
66 "jellyfin://:@/",
67 {
68 "instance": None,
69 },
70 ),
71 # Valid Authentication (we do not validate credentials here)
72 (
73 "jellyfin://l2g@localhost",
74 {
75 "instance": jellyfin.NotifyJellyfin,
76 # Authentication can't be validated through these unit tests
77 "response": False,
78 },
79 ),
80 (
81 "jellyfins://l2g:password@localhost",
82 {
83 "instance": jellyfin.NotifyJellyfin,
84 "response": False,
85 "privacy_url": "jellyfins://l2g:****@localhost",
86 },
87 ),
88 )
89
90
91 def test_plugin_jellyfin_urls():
92 """NotifyJellyfin() Apprise URLs."""
93
94 # Run our general tests
95 AppriseURLTester(tests=apprise_url_tests).run_all()
96
97
98 def test_plugin_jellyfin_instantiation():
99 """NotifyJellyfin() instantiation tests."""
100
101 obj = Apprise.instantiate("jellyfin://l2g:l2gpass@localhost")
102 assert isinstance(obj, jellyfin.NotifyJellyfin)
103
104 obj = Apprise.instantiate("jellyfins://l2g:l2gpass@localhost")
105 assert isinstance(obj, jellyfin.NotifyJellyfin)