mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-01-07 11:40:01 -08:00
dab46249f2
* Bump websocket-client from 1.7.0 to 1.8.0 Bumps [websocket-client](https://github.com/websocket-client/websocket-client) from 1.7.0 to 1.8.0. - [Release notes](https://github.com/websocket-client/websocket-client/releases) - [Changelog](https://github.com/websocket-client/websocket-client/blob/master/ChangeLog) - [Commits](https://github.com/websocket-client/websocket-client/compare/v1.7.0...v1.8.0) --- updated-dependencies: - dependency-name: websocket-client dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update websocket-client==1.8.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
124 lines
4.3 KiB
Python
124 lines
4.3 KiB
Python
import unittest
|
|
|
|
from websocket._cookiejar import SimpleCookieJar
|
|
|
|
"""
|
|
test_cookiejar.py
|
|
websocket - WebSocket client library for Python
|
|
|
|
Copyright 2024 engn33r
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
"""
|
|
|
|
|
|
class CookieJarTest(unittest.TestCase):
|
|
def test_add(self):
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.add("")
|
|
self.assertFalse(
|
|
cookie_jar.jar, "Cookie with no domain should not be added to the jar"
|
|
)
|
|
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.add("a=b")
|
|
self.assertFalse(
|
|
cookie_jar.jar, "Cookie with no domain should not be added to the jar"
|
|
)
|
|
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.add("a=b; domain=.abc")
|
|
self.assertTrue(".abc" in cookie_jar.jar)
|
|
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.add("a=b; domain=abc")
|
|
self.assertTrue(".abc" in cookie_jar.jar)
|
|
self.assertTrue("abc" not in cookie_jar.jar)
|
|
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.add("a=b; c=d; domain=abc")
|
|
self.assertEqual(cookie_jar.get("abc"), "a=b; c=d")
|
|
self.assertEqual(cookie_jar.get(None), "")
|
|
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.add("a=b; c=d; domain=abc")
|
|
cookie_jar.add("e=f; domain=abc")
|
|
self.assertEqual(cookie_jar.get("abc"), "a=b; c=d; e=f")
|
|
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.add("a=b; c=d; domain=abc")
|
|
cookie_jar.add("e=f; domain=.abc")
|
|
self.assertEqual(cookie_jar.get("abc"), "a=b; c=d; e=f")
|
|
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.add("a=b; c=d; domain=abc")
|
|
cookie_jar.add("e=f; domain=xyz")
|
|
self.assertEqual(cookie_jar.get("abc"), "a=b; c=d")
|
|
self.assertEqual(cookie_jar.get("xyz"), "e=f")
|
|
self.assertEqual(cookie_jar.get("something"), "")
|
|
|
|
def test_set(self):
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.set("a=b")
|
|
self.assertFalse(
|
|
cookie_jar.jar, "Cookie with no domain should not be added to the jar"
|
|
)
|
|
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.set("a=b; domain=.abc")
|
|
self.assertTrue(".abc" in cookie_jar.jar)
|
|
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.set("a=b; domain=abc")
|
|
self.assertTrue(".abc" in cookie_jar.jar)
|
|
self.assertTrue("abc" not in cookie_jar.jar)
|
|
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.set("a=b; c=d; domain=abc")
|
|
self.assertEqual(cookie_jar.get("abc"), "a=b; c=d")
|
|
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.set("a=b; c=d; domain=abc")
|
|
cookie_jar.set("e=f; domain=abc")
|
|
self.assertEqual(cookie_jar.get("abc"), "e=f")
|
|
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.set("a=b; c=d; domain=abc")
|
|
cookie_jar.set("e=f; domain=.abc")
|
|
self.assertEqual(cookie_jar.get("abc"), "e=f")
|
|
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.set("a=b; c=d; domain=abc")
|
|
cookie_jar.set("e=f; domain=xyz")
|
|
self.assertEqual(cookie_jar.get("abc"), "a=b; c=d")
|
|
self.assertEqual(cookie_jar.get("xyz"), "e=f")
|
|
self.assertEqual(cookie_jar.get("something"), "")
|
|
|
|
def test_get(self):
|
|
cookie_jar = SimpleCookieJar()
|
|
cookie_jar.set("a=b; c=d; domain=abc.com")
|
|
self.assertEqual(cookie_jar.get("abc.com"), "a=b; c=d")
|
|
self.assertEqual(cookie_jar.get("x.abc.com"), "a=b; c=d")
|
|
self.assertEqual(cookie_jar.get("abc.com.es"), "")
|
|
self.assertEqual(cookie_jar.get("xabc.com"), "")
|
|
|
|
cookie_jar.set("a=b; c=d; domain=.abc.com")
|
|
self.assertEqual(cookie_jar.get("abc.com"), "a=b; c=d")
|
|
self.assertEqual(cookie_jar.get("x.abc.com"), "a=b; c=d")
|
|
self.assertEqual(cookie_jar.get("abc.com.es"), "")
|
|
self.assertEqual(cookie_jar.get("xabc.com"), "")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|