mirror of
https://github.com/LukeHagar/plexpy.git
synced 2025-12-10 12:47:45 +00:00
SDK update generated by liblab
This commit is contained in:
71
test/services/test_updater.py
Normal file
71
test/services/test_updater.py
Normal file
@@ -0,0 +1,71 @@
|
||||
import unittest
|
||||
import responses
|
||||
from src.plexsdk.net.http_client import HTTPClient
|
||||
from http_exceptions import ClientException
|
||||
from src.plexsdk.services.updater import Updater
|
||||
|
||||
|
||||
class TestUpdater_(unittest.TestCase):
|
||||
def test_true(self):
|
||||
self.assertTrue(True)
|
||||
|
||||
@responses.activate
|
||||
def test_get_update_status(self):
|
||||
# Mock the API response
|
||||
responses.get("{protocol}://{ip}:{port}/updater/status", json={}, status=200)
|
||||
# call the method to test
|
||||
test_service = Updater("testkey")
|
||||
response = test_service.get_update_status()
|
||||
self.assertEqual(response.data, {})
|
||||
responses.reset(),
|
||||
|
||||
@responses.activate
|
||||
def test_get_update_status_error_on_non_200(self):
|
||||
# Mock the API response
|
||||
responses.get("{protocol}://{ip}:{port}/updater/status", json={}, status=404)
|
||||
with self.assertRaises(ClientException):
|
||||
test_service = Updater("testkey")
|
||||
test_service.get_update_status()
|
||||
responses.reset()
|
||||
|
||||
@responses.activate
|
||||
def test_check_for_updates(self):
|
||||
# Mock the API response
|
||||
responses.put("{protocol}://{ip}:{port}/updater/check", json={}, status=200)
|
||||
# call the method to test
|
||||
test_service = Updater("testkey")
|
||||
response = test_service.check_for_updates("foo")
|
||||
self.assertEqual(response.data, {})
|
||||
responses.reset(),
|
||||
|
||||
@responses.activate
|
||||
def test_check_for_updates_error_on_non_200(self):
|
||||
# Mock the API response
|
||||
responses.put("{protocol}://{ip}:{port}/updater/check", json={}, status=404)
|
||||
with self.assertRaises(ClientException):
|
||||
test_service = Updater("testkey")
|
||||
test_service.check_for_updates("foo")
|
||||
responses.reset()
|
||||
|
||||
@responses.activate
|
||||
def test_apply_updates(self):
|
||||
# Mock the API response
|
||||
responses.put("{protocol}://{ip}:{port}/updater/apply", json={}, status=200)
|
||||
# call the method to test
|
||||
test_service = Updater("testkey")
|
||||
response = test_service.apply_updates("foo", "foo")
|
||||
self.assertEqual(response.data, {})
|
||||
responses.reset(),
|
||||
|
||||
@responses.activate
|
||||
def test_apply_updates_error_on_non_200(self):
|
||||
# Mock the API response
|
||||
responses.put("{protocol}://{ip}:{port}/updater/apply", json={}, status=404)
|
||||
with self.assertRaises(ClientException):
|
||||
test_service = Updater("testkey")
|
||||
test_service.apply_updates("foo", "foo")
|
||||
responses.reset()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user