def test_inner_logout_exception(self, mlr_m): mlr_m.side_effect = DownloaderError("message") conn = Connection() with pytest.raises(LogoutError, match="Logout request raised DownloaderError"): conn.inner_logout() mlr_m.assert_called_once_with() self.scc_m.assert_not_called()
def test_inner_logout_http_status_error(self, mlr_m, status_code): response = mock.MagicMock(ok=False, status_code=status_code) mlr_m.return_value = response conn = Connection() with pytest.raises(LogoutError, match=f"Logout returned {status_code}"): conn.inner_logout() mlr_m.assert_called_once_with() self.scc_m.assert_not_called()
def test_inner_logout_ok(self, mlr_m): # TODO: put real text text = "Usted no se ha identificado. Pulse aquí para hacerlo." response = mock.MagicMock(ok=True, status_code=200, text=text) mlr_m.return_value = response conn = Connection() conn.inner_logout() mlr_m.assert_called_once_with() self.scc_m.assert_not_called()
def test_inner_logout_fatal_logout(self, mlr_m): # TODO: put real text text = "Identificado como FEDERICO GARCÍA LORCA." response = mock.MagicMock(ok=True, status_code=200, text=text) mlr_m.return_value = response conn = Connection() with pytest.raises(LogoutError, match="Unkown error during logout"): conn.inner_logout() mlr_m.assert_called_once_with() self.scc_m.assert_called_once_with(conn, mock.ANY, mock.ANY)