PyPtt 2.3.0__tar.gz → 2.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyptt-2.3.0 → pyptt-2.3.1}/PKG-INFO +1 -1
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/PTT.py +3 -2
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/__init__.py +1 -1
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_mail.py +2 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_reply_post.py +5 -2
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt.egg-info/PKG-INFO +1 -1
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt.egg-info/SOURCES.txt +1 -0
- pyptt-2.3.1/tests/test_backup_param.py +41 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/LICENSE +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_bucket.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_call_status.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_change_pw.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_comment.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_del_post.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_get_board_info.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_get_board_list.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_get_bottom_post_list.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_get_favourite_board.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_get_newest_index.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_get_post.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_get_post_index.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_get_post_list.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_get_time.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_get_user.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_get_waterball.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_give_money.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_has_new_mail.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_loginout.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_mark_post.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_post.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_search_user.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_set_board_title.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_set_signature_file.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_api_util.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_uao/LICENSE +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_uao/__init__.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_uao/b2u.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/_uao/u2b.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/api_server.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/check_value.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/command.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/config.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/connect_core.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/data_type.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/exceptions.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/i18n.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/lang_en_US.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/lang_zh_TW.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/lib_util.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/log.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/screens.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/service.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt/ssl_config.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt.egg-info/dependency_links.txt +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt.egg-info/requires.txt +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/PyPtt.egg-info/top_level.txt +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/README.md +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/pyproject.toml +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/setup.cfg +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/setup.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_bucket.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_change_pw.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_comment.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_connect_core_timeout.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_del_post.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_del_post_unit.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_exceptions.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_fast_post.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_get_board_info.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_get_board_list.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_get_bottom_post_list.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_get_content_formula.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_get_favourite_boards.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_get_mail.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_get_newest_index.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_get_post.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_get_post_list.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_get_post_list_parser.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_get_post_parser.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_get_time.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_get_user.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_get_waterball.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_give_money.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_half_dead_connection.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_i18n.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_incremental_parity.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_init.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_logger.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_login_logout.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_mail_send_and_del.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_mark_post.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_parse_query_post.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_post.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_post_anonymous.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_pyte_parity.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_reply_post.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_search_user.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_service.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_set_board_title.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_set_signature_file.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_uao_codec.py +0 -0
- {pyptt-2.3.0 → pyptt-2.3.1}/tests/test_vt100_parser.py +0 -0
|
@@ -665,7 +665,7 @@ class API:
|
|
|
665
665
|
return _api_get_board_list.get_board_list(self)
|
|
666
666
|
|
|
667
667
|
def reply_post(self, reply_to: data_type.ReplyTo, board: str, content: str, sign_file: [str | int] = 0,
|
|
668
|
-
aid: Optional[str] = None, index: int = 0) -> None:
|
|
668
|
+
aid: Optional[str] = None, index: int = 0, backup: bool = True) -> None:
|
|
669
669
|
|
|
670
670
|
"""
|
|
671
671
|
回覆文章。
|
|
@@ -677,6 +677,7 @@ class API:
|
|
|
677
677
|
sign_file (str | int): 編號或隨機簽名檔 (x),預設為 **0** (不選)。
|
|
678
678
|
aid: 文章編號。
|
|
679
679
|
index: 文章編號。
|
|
680
|
+
backup (bool): 回信給作者時是否自存底稿,預設為 True。僅在回覆類型含站內信時有作用。
|
|
680
681
|
|
|
681
682
|
Returns:
|
|
682
683
|
None
|
|
@@ -703,7 +704,7 @@ class API:
|
|
|
703
704
|
參考 :ref:`回覆類型 <reply-to>`、:ref:`取得最新文章編號 <api-get-newest-index>`
|
|
704
705
|
"""
|
|
705
706
|
|
|
706
|
-
_api_reply_post.reply_post(self, reply_to, board, content, sign_file, aid, index)
|
|
707
|
+
_api_reply_post.reply_post(self, reply_to, board, content, sign_file, aid, index, backup)
|
|
707
708
|
|
|
708
709
|
def set_board_title(self, board: str, new_title: str) -> None:
|
|
709
710
|
"""
|
|
@@ -34,6 +34,8 @@ def mail(api,
|
|
|
34
34
|
check_value.check_type(ptt_id, str, 'ptt_id')
|
|
35
35
|
check_value.check_type(title, str, 'title')
|
|
36
36
|
check_value.check_type(content, str, 'content')
|
|
37
|
+
# 沒擋型別的話,backup='False' 這種字串是 truthy,會靜靜地存底稿。
|
|
38
|
+
check_value.check_type(backup, bool, 'backup')
|
|
37
39
|
|
|
38
40
|
_api_util.check_user_exist(api, ptt_id)
|
|
39
41
|
|
|
@@ -10,7 +10,7 @@ from . import log
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def reply_post(api, reply_to: data_type.ReplyTo, board: str, content: str, sign_file, post_aid: str,
|
|
13
|
-
post_index: int) -> None:
|
|
13
|
+
post_index: int, backup: bool = True) -> None:
|
|
14
14
|
_api_util.one_thread(api)
|
|
15
15
|
|
|
16
16
|
if not api._is_login:
|
|
@@ -21,6 +21,8 @@ def reply_post(api, reply_to: data_type.ReplyTo, board: str, content: str, sign_
|
|
|
21
21
|
|
|
22
22
|
check_value.check_type(board, str, 'board')
|
|
23
23
|
check_value.check_type(content, str, 'content')
|
|
24
|
+
# 沒擋型別的話,backup='False' 這種字串是 truthy,會靜靜地存底稿。
|
|
25
|
+
check_value.check_type(backup, bool, 'backup')
|
|
24
26
|
if post_aid is not None:
|
|
25
27
|
check_value.check_type(post_aid, str, 'PostAID')
|
|
26
28
|
|
|
@@ -85,7 +87,8 @@ def reply_post(api, reply_to: data_type.ReplyTo, board: str, content: str, sign_
|
|
|
85
87
|
connect_core.TargetUnit('請問要引用原文嗎', log_level=log.DEBUG, response='Y' + command.enter),
|
|
86
88
|
connect_core.TargetUnit('採用原標題[Y/n]?', log_level=log.DEBUG, response='Y' + command.enter),
|
|
87
89
|
reply_target_unit,
|
|
88
|
-
connect_core.TargetUnit('已順利寄出,是否自存底稿', log_level=log.DEBUG,
|
|
90
|
+
connect_core.TargetUnit('已順利寄出,是否自存底稿', log_level=log.DEBUG,
|
|
91
|
+
response=('Y' if backup else 'N') + command.enter),
|
|
89
92
|
]
|
|
90
93
|
|
|
91
94
|
api.connect_core.send(
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""
|
|
2
|
+
No-network unit tests for the `backup` parameter of mail / reply_post.
|
|
3
|
+
|
|
4
|
+
Regression guard: `backup` used to skip check_type, so a truthy non-bool
|
|
5
|
+
like the string 'False' silently answered 是否自存底稿 with 'y' and left a
|
|
6
|
+
backup in the sender's mailbox. `reply_post` had no `backup` parameter at
|
|
7
|
+
all and always answered 'Y'.
|
|
8
|
+
"""
|
|
9
|
+
import threading
|
|
10
|
+
|
|
11
|
+
import pytest
|
|
12
|
+
|
|
13
|
+
import PyPtt
|
|
14
|
+
from PyPtt import _api_mail, _api_reply_post
|
|
15
|
+
|
|
16
|
+
NON_BOOLS = ['False', 'false', '0', 0, 1, None]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class _StubAPI:
|
|
20
|
+
"""Just enough of PyPtt.API to reach the parameter checks."""
|
|
21
|
+
_thread_id = threading.get_ident()
|
|
22
|
+
_is_login = True
|
|
23
|
+
is_registered_user = True
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@pytest.mark.parametrize('backup', NON_BOOLS)
|
|
27
|
+
def test_mail_non_bool_backup_raises(backup):
|
|
28
|
+
with pytest.raises(TypeError):
|
|
29
|
+
_api_mail.mail(_StubAPI(), 'someone', 'title', 'content', 0, backup)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@pytest.mark.parametrize('backup', NON_BOOLS)
|
|
33
|
+
def test_reply_post_non_bool_backup_raises(backup):
|
|
34
|
+
with pytest.raises(TypeError):
|
|
35
|
+
_api_reply_post.reply_post(_StubAPI(), PyPtt.ReplyTo.BOARD, 'Test', 'content', 0, None, 1, backup)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_reply_post_exposes_backup():
|
|
39
|
+
"""回信給作者時的自存底稿以前寫死 'Y',關不掉。"""
|
|
40
|
+
import inspect
|
|
41
|
+
assert inspect.signature(PyPtt.API.reply_post).parameters['backup'].default is True
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|