Merge pull request #588 from oddstr13/fix/587

Avoid circular imports of database
This commit is contained in:
mcarlton00 2021-10-19 10:57:36 -04:00 committed by GitHub
commit bae3ee9346
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 121 additions and 11 deletions

View file

@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera
################################################################################################# #################################################################################################
from jellyfin_kodi.entrypoint import Context from jellyfin_kodi.entrypoint.context import Context
from jellyfin_kodi.helper import LazyLogger from jellyfin_kodi.helper import LazyLogger
################################################################################################# #################################################################################################

View file

@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera
################################################################################################# #################################################################################################
from jellyfin_kodi.entrypoint import Context from jellyfin_kodi.entrypoint.context import Context
from jellyfin_kodi.helper import LazyLogger from jellyfin_kodi.helper import LazyLogger
################################################################################################# #################################################################################################

View file

@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera
################################################################################################# #################################################################################################
from jellyfin_kodi.entrypoint import Events from jellyfin_kodi.entrypoint.default import Events
from jellyfin_kodi.helper import LazyLogger from jellyfin_kodi.helper import LazyLogger
################################################################################################# #################################################################################################

View file

@ -6,8 +6,4 @@ from __future__ import division, absolute_import, print_function, unicode_litera
from ..helper import LazyLogger from ..helper import LazyLogger
from ..jellyfin import Jellyfin from ..jellyfin import Jellyfin
from .default import Events
from .service import Service
from .context import Context
################################################################################################# #################################################################################################

View file

@ -36,7 +36,12 @@ def addon_id():
def kodi_version(): def kodi_version():
# Kodistubs returns empty string, causing Python 3 tests to choke on int() # Kodistubs returns empty string, causing Python 3 tests to choke on int()
# TODO: Make Kodistubs version configurable for testing purposes # TODO: Make Kodistubs version configurable for testing purposes
version_string = xbmc.getInfoLabel('System.BuildVersion') or "19.1 (19.1.0) Git:20210509-85e05228b4" if sys.version_info.major == 2:
default_versionstring = "18"
else:
default_versionstring = "19.1 (19.1.0) Git:20210509-85e05228b4"
version_string = xbmc.getInfoLabel('System.BuildVersion') or default_versionstring
return int(version_string.split(' ', 1)[0].split('.', 1)[0]) return int(version_string.split(' ', 1)[0].split('.', 1)[0])

View file

@ -10,7 +10,6 @@ from datetime import timedelta
from kodi_six import xbmc, xbmcgui, xbmcplugin, xbmcaddon from kodi_six import xbmc, xbmcgui, xbmcplugin, xbmcaddon
from .. import database
from ..helper import translate, playutils, api, window, settings, dialog from ..helper import translate, playutils, api, window, settings, dialog
from ..dialogs import resume from ..dialogs import resume
from ..helper import LazyLogger from ..helper import LazyLogger
@ -724,6 +723,7 @@ def on_update(data, server):
return return
from .. import database
item = database.get_item(kodi_id, media) item = database.get_item(kodi_id, media)
if item: if item:
@ -767,6 +767,7 @@ def on_play(data, server):
return return
if settings('useDirectPaths') == '1' or media == 'song': if settings('useDirectPaths') == '1' or media == 'song':
from .. import database
item = database.get_item(kodi_id, media) item = database.get_item(kodi_id, media)
if item: if item:

View file

@ -286,7 +286,7 @@ VALUES (?, ?, ?, ?)
add_movie = """ add_movie = """
INSERT INTO movie(idMovie, idFile, c00, c01, c02, c03, c04, c05, c06, c07, INSERT INTO movie(idMovie, idFile, c00, c01, c02, c03, c04, c05, c06, c07,
c09, c10, c11, c12, c14, c15, c16, c18, c19, c21, premiered) c09, c10, c11, c12, c14, c15, c16, c18, c19, c21, premiered)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""" """
add_movie_obj = ["{MovieId}", "{FileId}", "{Title}", "{Plot}", "{ShortPlot}", "{Tagline}", add_movie_obj = ["{MovieId}", "{FileId}", "{Title}", "{Plot}", "{ShortPlot}", "{Tagline}",
"{Votes}", "{RatingId}", "{Writers}", "{Year}", "{Unique}", "{SortTitle}", "{Votes}", "{RatingId}", "{Writers}", "{Year}", "{Unique}", "{SortTitle}",

View file

@ -7,7 +7,7 @@ import threading
from kodi_six import xbmc from kodi_six import xbmc
from jellyfin_kodi.entrypoint import Service from jellyfin_kodi.entrypoint.service import Service
from jellyfin_kodi.helper.utils import settings from jellyfin_kodi.helper.utils import settings
from jellyfin_kodi.helper import LazyLogger from jellyfin_kodi.helper import LazyLogger

107
tests/test_imports.py Normal file
View file

@ -0,0 +1,107 @@
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
def test_import_main_module():
import jellyfin_kodi # noqa: F401
def test_import_client():
import jellyfin_kodi.client # noqa: F401
def test_import_connect():
import jellyfin_kodi.connect # noqa: F401
def test_import_database():
import jellyfin_kodi.database
import jellyfin_kodi.database.jellyfin_db
import jellyfin_kodi.database.queries # noqa: F401
def test_import_dialogs():
import jellyfin_kodi.dialogs
import jellyfin_kodi.dialogs.context
import jellyfin_kodi.dialogs.loginmanual
import jellyfin_kodi.dialogs.resume
import jellyfin_kodi.dialogs.serverconnect
import jellyfin_kodi.dialogs.servermanual
import jellyfin_kodi.dialogs.usersconnect # noqa: F401
def test_import_downloader():
import jellyfin_kodi.downloader # noqa: F401
def test_import_entrypoint():
import jellyfin_kodi.entrypoint
import jellyfin_kodi.entrypoint.context
# import jellyfin_kodi.entrypoint.default # FIXME: Messes with sys.argv
import jellyfin_kodi.entrypoint.service # noqa: F401
def test_import_full_sync():
import jellyfin_kodi.full_sync # noqa: F401
def test_import_helper():
import jellyfin_kodi.helper
import jellyfin_kodi.helper.api
import jellyfin_kodi.helper.exceptions
import jellyfin_kodi.helper.lazylogger
import jellyfin_kodi.helper.loghandler
import jellyfin_kodi.helper.playutils
import jellyfin_kodi.helper.translate
import jellyfin_kodi.helper.utils
import jellyfin_kodi.helper.wrapper
import jellyfin_kodi.helper.xmls # noqa: F401
def test_import_jellyfin():
import jellyfin_kodi.jellyfin
import jellyfin_kodi.jellyfin.api
import jellyfin_kodi.jellyfin.client
import jellyfin_kodi.jellyfin.configuration
import jellyfin_kodi.jellyfin.connection_manager
import jellyfin_kodi.jellyfin.credentials
import jellyfin_kodi.jellyfin.http
import jellyfin_kodi.jellyfin.utils
import jellyfin_kodi.jellyfin.ws_client # noqa: F401
def test_import_library():
import jellyfin_kodi.library # noqa: F401
def test_import_monitor():
import jellyfin_kodi.monitor # noqa: F401
def test_import_objects():
import jellyfin_kodi.objects
import jellyfin_kodi.objects.actions
import jellyfin_kodi.objects.kodi
import jellyfin_kodi.objects.kodi.artwork
import jellyfin_kodi.objects.kodi.kodi
import jellyfin_kodi.objects.kodi.movies
import jellyfin_kodi.objects.kodi.music
import jellyfin_kodi.objects.kodi.musicvideos
import jellyfin_kodi.objects.kodi.queries
import jellyfin_kodi.objects.kodi.queries_music
import jellyfin_kodi.objects.kodi.queries_texture
import jellyfin_kodi.objects.kodi.tvshows
import jellyfin_kodi.objects.movies
import jellyfin_kodi.objects.music
import jellyfin_kodi.objects.musicvideos
import jellyfin_kodi.objects.obj
import jellyfin_kodi.objects.tvshows
import jellyfin_kodi.objects.utils # noqa: F401
def test_import_player():
import jellyfin_kodi.player # noqa: F401
def test_import_views():
import jellyfin_kodi.views # noqa: F401

View file

@ -6,6 +6,7 @@ extend-ignore =
I202 I202
per-file-ignores = per-file-ignores =
*/__init__.py: F401 */__init__.py: F401
tests/test_imports.py: F401
[pytest] [pytest]
minversion = 4.6 minversion = 4.6