예제 #1
0
def main():
    try:
        resolve(player.get_current_url())
    except kinoman_api.LoginError as error:
        player.dialog_ok("Kinoman.Uz", "Ошибка авторизации: {}".format(error))
    except kinoman_api.MissingVideoError:
        player.dialog_ok("Kinoman.Uz", "Видео отсутствует")
    except kinoman_api.NetworkError:
        player.dialog_ok("Kinoman.Uz", "Проблема сети, попробуйте позже")
예제 #2
0
    def test_good_resolve_with_args(self):
        # pylint: disable=unused-argument
        # noinspection PyUnusedLocal
        def test_function(search_query):
            pass

        test_function = mock.MagicMock(spec=test_function)
        test_function.__code__.co_varnames = ["search_query"]

        router.route("/search/<search_query>")(test_function)
        router.resolve("plugin://test_plugin/search/something")

        test_function.assert_called_once_with(search_query="something")
예제 #3
0
    def test_good_resolve_no_args(self):
        def test_function():
            pass

        test_function = mock.MagicMock(spec=test_function)

        router.route("/other/path1")(test_function)
        router.route("/other/path2")(test_function)
        router.route("/")(test_function)
        router.resolve("plugin://test_plugin/")
        router.resolve("plugin://test_plugin/other/path1")

        test_function.assert_has_calls([mock.call(), mock.call()])
예제 #4
0
    def test_good_resolve_with_args_multiple_types(self):
        # pylint: disable=unused-argument
        # noinspection PyUnusedLocal
        def test_function(test_parameter):
            pass

        test_function = mock.MagicMock(spec=test_function)
        test_function.__code__.co_varnames = ["test_parameter"]

        router.route("/page/<int:test_parameter>")(test_function)
        router.route("/page/<float:test_parameter>")(test_function)
        router.resolve("plugin://test_plugin/page/10")

        test_function.assert_called_once_with(test_parameter=10)
예제 #5
0
 def test_exception_bad_url(self):
     with self.assertRaisesRegexp(ValueError,
                                  r"^Failed to resolve the url .*"):
         router.resolve("plugin://test_plugin/search/something?testing=123")