Beispiel #1
0
def test_on_start_logged(caplog):
    caplog.set_level(logging.INFO)
    connection = Mock(spec=network.Connection)

    session.MpdSession(connection).on_start()

    assert f"New MPD connection from {connection}" in caplog.text
Beispiel #2
0
    def setUp(self):  # noqa: N802
        if self.enable_mixer:
            self.mixer = dummy_mixer.create_proxy()
        else:
            self.mixer = None
        self.audio = dummy_audio.create_proxy()
        self.backend = dummy_backend.create_proxy(audio=self.audio)

        self.core = core.Core.start(
            self.get_config(),
            audio=self.audio,
            mixer=self.mixer,
            backends=[self.backend],
        ).proxy()

        self.uri_map = uri_mapper.MpdUriMapper(self.core)
        self.connection = MockConnection()
        self.session = session.MpdSession(
            self.connection,
            config=self.get_config(),
            core=self.core,
            uri_map=self.uri_map,
        )
        self.dispatcher = self.session.dispatcher
        self.context = self.dispatcher.context
Beispiel #3
0
def test_on_line_received_logged(caplog):
    caplog.set_level(logging.DEBUG)
    connection = Mock(spec=network.Connection)
    mpd_session = session.MpdSession(connection)
    mpd_session.dispatcher = Mock(spec=dispatcher.MpdDispatcher)
    mpd_session.dispatcher.handle_request.return_value = [str(sentinel.resp)]

    mpd_session.on_line_received("foobar")

    assert f"Request from {connection}: foobar" in caplog.text
    assert f"Response to {connection}:" in caplog.text