mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-01-09 03:43:47 +01:00
Get a Number of Tests passing
This commit is contained in:
parent
2c6913a243
commit
04de3eff7a
43 changed files with 72 additions and 124 deletions
|
@ -71,6 +71,8 @@ TeleCrypto_co = TypeVar("TeleCrypto_co", bound="HasDecryptMethod", covariant=Tru
|
|||
|
||||
|
||||
class HasDecryptMethod(Protocol):
|
||||
__slots__ = ()
|
||||
|
||||
@classmethod
|
||||
def de_json_decrypted(
|
||||
cls: type[TeleCrypto_co],
|
||||
|
|
|
@ -138,7 +138,9 @@ class TestAnimationWithoutRequest(AnimationTestBase):
|
|||
)
|
||||
|
||||
@pytest.mark.parametrize("local_mode", [True, False])
|
||||
async def test_send_animation_local_files(self, monkeypatch, offline_bot, chat_id, local_mode):
|
||||
async def test_send_animation_local_files(
|
||||
self, monkeypatch, offline_bot, chat_id, local_mode, dummy_message_dict
|
||||
):
|
||||
try:
|
||||
offline_bot._local_mode = local_mode
|
||||
# For just test that the correct paths are passed as we have no local Bot API set up
|
||||
|
@ -156,6 +158,7 @@ class TestAnimationWithoutRequest(AnimationTestBase):
|
|||
test_flag = isinstance(data.get("animation"), InputFile) and isinstance(
|
||||
data.get("thumbnail"), InputFile
|
||||
)
|
||||
return dummy_message_dict
|
||||
|
||||
monkeypatch.setattr(offline_bot, "_post", make_assertion)
|
||||
await offline_bot.send_animation(chat_id, file, thumbnail=file)
|
||||
|
|
|
@ -150,7 +150,9 @@ class TestAudioWithoutRequest(AudioTestBase):
|
|||
assert await offline_bot.send_audio(chat_id, audio_file, filename="custom_filename")
|
||||
|
||||
@pytest.mark.parametrize("local_mode", [True, False])
|
||||
async def test_send_audio_local_files(self, monkeypatch, offline_bot, chat_id, local_mode):
|
||||
async def test_send_audio_local_files(
|
||||
self, dummy_message_dict, monkeypatch, offline_bot, chat_id, local_mode
|
||||
):
|
||||
try:
|
||||
offline_bot._local_mode = local_mode
|
||||
# For just test that the correct paths are passed as we have no local Bot API set up
|
||||
|
@ -166,6 +168,7 @@ class TestAudioWithoutRequest(AudioTestBase):
|
|||
test_flag = isinstance(data.get("audio"), InputFile) and isinstance(
|
||||
data.get("thumbnail"), InputFile
|
||||
)
|
||||
return dummy_message_dict
|
||||
|
||||
monkeypatch.setattr(offline_bot, "_post", make_assertion)
|
||||
await offline_bot.send_audio(chat_id, file, thumbnail=file)
|
||||
|
|
|
@ -169,7 +169,9 @@ class TestDocumentWithoutRequest(DocumentTestBase):
|
|||
)
|
||||
|
||||
@pytest.mark.parametrize("local_mode", [True, False])
|
||||
async def test_send_document_local_files(self, monkeypatch, offline_bot, chat_id, local_mode):
|
||||
async def test_send_document_local_files(
|
||||
self, dummy_message_dict, monkeypatch, offline_bot, chat_id, local_mode
|
||||
):
|
||||
try:
|
||||
offline_bot._local_mode = local_mode
|
||||
# For just test that the correct paths are passed as we have no local Bot API set up
|
||||
|
@ -187,6 +189,7 @@ class TestDocumentWithoutRequest(DocumentTestBase):
|
|||
test_flag = isinstance(data.get("document"), InputFile) and isinstance(
|
||||
data.get("thumbnail"), InputFile
|
||||
)
|
||||
return dummy_message_dict
|
||||
|
||||
monkeypatch.setattr(offline_bot, "_post", make_assertion)
|
||||
await offline_bot.send_document(chat_id, file, thumbnail=file)
|
||||
|
|
|
@ -144,7 +144,9 @@ class TestPhotoWithoutRequest(PhotoTestBase):
|
|||
assert await offline_bot.send_photo(chat_id, photo_file, filename="custom_filename")
|
||||
|
||||
@pytest.mark.parametrize("local_mode", [True, False])
|
||||
async def test_send_photo_local_files(self, monkeypatch, offline_bot, chat_id, local_mode):
|
||||
async def test_send_photo_local_files(
|
||||
self, dummy_message_dict, monkeypatch, offline_bot, chat_id, local_mode
|
||||
):
|
||||
try:
|
||||
offline_bot._local_mode = local_mode
|
||||
# For just test that the correct paths are passed as we have no local Bot API set up
|
||||
|
@ -158,6 +160,7 @@ class TestPhotoWithoutRequest(PhotoTestBase):
|
|||
test_flag = data.get("photo") == expected
|
||||
else:
|
||||
test_flag = isinstance(data.get("photo"), InputFile)
|
||||
return dummy_message_dict
|
||||
|
||||
monkeypatch.setattr(offline_bot, "_post", make_assertion)
|
||||
await offline_bot.send_photo(chat_id, file)
|
||||
|
|
|
@ -256,7 +256,9 @@ class TestStickerWithoutRequest(StickerTestBase):
|
|||
assert await offline_bot.send_sticker(sticker=sticker, chat_id=chat_id)
|
||||
|
||||
@pytest.mark.parametrize("local_mode", [True, False])
|
||||
async def test_send_sticker_local_files(self, monkeypatch, offline_bot, chat_id, local_mode):
|
||||
async def test_send_sticker_local_files(
|
||||
self, dummy_message_dict, monkeypatch, offline_bot, chat_id, local_mode
|
||||
):
|
||||
try:
|
||||
offline_bot._local_mode = local_mode
|
||||
# For just test that the correct paths are passed as we have no local Bot API set up
|
||||
|
@ -270,6 +272,7 @@ class TestStickerWithoutRequest(StickerTestBase):
|
|||
test_flag = data.get("sticker") == expected
|
||||
else:
|
||||
test_flag = isinstance(data.get("sticker"), InputFile)
|
||||
return dummy_message_dict
|
||||
|
||||
monkeypatch.setattr(offline_bot, "_post", make_assertion)
|
||||
await offline_bot.send_sticker(chat_id, file)
|
||||
|
@ -581,6 +584,7 @@ class TestStickerSetWithoutRequest(StickerSetTestBase):
|
|||
if local_mode
|
||||
else isinstance(data.get("sticker"), InputFile)
|
||||
)
|
||||
return File(file_id="file_id", file_unique_id="file_unique_id").to_dict()
|
||||
|
||||
monkeypatch.setattr(offline_bot, "_post", make_assertion)
|
||||
await offline_bot.upload_sticker_file(
|
||||
|
|
|
@ -157,7 +157,9 @@ class TestVideoWithoutRequest(VideoTestBase):
|
|||
assert await offline_bot.send_video(chat_id, video_file, filename="custom_filename")
|
||||
|
||||
@pytest.mark.parametrize("local_mode", [True, False])
|
||||
async def test_send_video_local_files(self, monkeypatch, offline_bot, chat_id, local_mode):
|
||||
async def test_send_video_local_files(
|
||||
self, dummy_message_dict, monkeypatch, offline_bot, chat_id, local_mode
|
||||
):
|
||||
try:
|
||||
offline_bot._local_mode = local_mode
|
||||
# For just test that the correct paths are passed as we have no local Bot API set up
|
||||
|
@ -173,6 +175,7 @@ class TestVideoWithoutRequest(VideoTestBase):
|
|||
test_flag = isinstance(data.get("video"), InputFile) and isinstance(
|
||||
data.get("thumbnail"), InputFile
|
||||
)
|
||||
return dummy_message_dict
|
||||
|
||||
monkeypatch.setattr(offline_bot, "_post", make_assertion)
|
||||
await offline_bot.send_video(chat_id, file, thumbnail=file)
|
||||
|
|
|
@ -157,7 +157,7 @@ class TestVideoNoteWithoutRequest(VideoNoteTestBase):
|
|||
|
||||
@pytest.mark.parametrize("local_mode", [True, False])
|
||||
async def test_send_video_note_local_files(
|
||||
self, monkeypatch, offline_bot, chat_id, local_mode
|
||||
self, monkeypatch, offline_bot, chat_id, local_mode, dummy_message_dict
|
||||
):
|
||||
try:
|
||||
offline_bot._local_mode = local_mode
|
||||
|
@ -176,6 +176,7 @@ class TestVideoNoteWithoutRequest(VideoNoteTestBase):
|
|||
test_flag = isinstance(data.get("video_note"), InputFile) and isinstance(
|
||||
data.get("thumbnail"), InputFile
|
||||
)
|
||||
return dummy_message_dict
|
||||
|
||||
monkeypatch.setattr(offline_bot, "_post", make_assertion)
|
||||
await offline_bot.send_video_note(chat_id, file, thumbnail=file)
|
||||
|
|
|
@ -145,7 +145,9 @@ class TestVoiceWithoutRequest(VoiceTestBase):
|
|||
assert await offline_bot.send_voice(chat_id, voice=voice)
|
||||
|
||||
@pytest.mark.parametrize("local_mode", [True, False])
|
||||
async def test_send_voice_local_files(self, monkeypatch, offline_bot, chat_id, local_mode):
|
||||
async def test_send_voice_local_files(
|
||||
self, dummy_message_dict, monkeypatch, offline_bot, chat_id, local_mode
|
||||
):
|
||||
try:
|
||||
offline_bot._local_mode = local_mode
|
||||
# For just test that the correct paths are passed as we have no local Bot API set up
|
||||
|
@ -159,6 +161,7 @@ class TestVoiceWithoutRequest(VoiceTestBase):
|
|||
test_flag = data.get("voice") == expected
|
||||
else:
|
||||
test_flag = isinstance(data.get("voice"), InputFile)
|
||||
return dummy_message_dict
|
||||
|
||||
monkeypatch.setattr(offline_bot, "_post", make_assertion)
|
||||
await offline_bot.send_voice(chat_id, file)
|
||||
|
|
|
@ -55,8 +55,6 @@ class TestGameHighScoreWithoutRequest(GameHighScoreTestBase):
|
|||
assert highscore.user == self.user
|
||||
assert highscore.score == self.score
|
||||
|
||||
assert GameHighScore.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, game_highscore):
|
||||
game_highscore_dict = game_highscore.to_dict()
|
||||
|
||||
|
|
|
@ -159,9 +159,6 @@ class TestInlineKeyboardButtonWithoutRequest(InlineKeyboardButtonTestBase):
|
|||
)
|
||||
assert inline_keyboard_button.copy_text == self.copy_text
|
||||
|
||||
none = InlineKeyboardButton.de_json({}, offline_bot)
|
||||
assert none is None
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineKeyboardButton("text", callback_data="data")
|
||||
b = InlineKeyboardButton("text", callback_data="data")
|
||||
|
|
|
@ -204,7 +204,6 @@ class TestInputInvoiceMessageContentWithoutRequest(InputInvoiceMessageContentTes
|
|||
)
|
||||
|
||||
def test_de_json(self, offline_bot):
|
||||
assert InputInvoiceMessageContent.de_json({}, bot=offline_bot) is None
|
||||
|
||||
json_dict = {
|
||||
"title": self.title,
|
||||
|
|
|
@ -64,9 +64,6 @@ class TestAffiliateInfoWithoutRequest(AffiliateInfoTestBase):
|
|||
assert ai.amount == self.amount
|
||||
assert ai.nanostar_amount == self.nanostar_amount
|
||||
|
||||
assert AffiliateInfo.de_json(None, offline_bot) is None
|
||||
assert AffiliateInfo.de_json({}, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, affiliate_info):
|
||||
ai_dict = affiliate_info.to_dict()
|
||||
|
||||
|
|
|
@ -77,9 +77,6 @@ class TestRevenueWithdrawalStateWithoutRequest(RevenueWithdrawalStateTestBase):
|
|||
assert rws.api_kwargs == {}
|
||||
assert rws.type == "unknown"
|
||||
|
||||
assert RevenueWithdrawalState.de_json(None, offline_bot) is None
|
||||
assert RevenueWithdrawalState.de_json({}, offline_bot) is None
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("state", "subclass"),
|
||||
[
|
||||
|
@ -129,8 +126,6 @@ class TestRevenueWithdrawalStatePendingWithoutRequest(RevenueWithdrawalStateTest
|
|||
assert rws.api_kwargs == {}
|
||||
assert rws.type == "pending"
|
||||
|
||||
assert RevenueWithdrawalStatePending.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, revenue_withdrawal_state_pending):
|
||||
json_dict = revenue_withdrawal_state_pending.to_dict()
|
||||
assert json_dict == {"type": "pending"}
|
||||
|
@ -168,8 +163,6 @@ class TestRevenueWithdrawalStateSucceededWithoutRequest(RevenueWithdrawalStateTe
|
|||
assert rws.date == self.date
|
||||
assert rws.url == self.url
|
||||
|
||||
assert RevenueWithdrawalStateSucceeded.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, revenue_withdrawal_state_succeeded):
|
||||
json_dict = revenue_withdrawal_state_succeeded.to_dict()
|
||||
assert json_dict["type"] == "succeeded"
|
||||
|
@ -213,8 +206,6 @@ class TestRevenueWithdrawalStateFailedWithoutRequest(RevenueWithdrawalStateTestB
|
|||
assert rws.api_kwargs == {}
|
||||
assert rws.type == "failed"
|
||||
|
||||
assert RevenueWithdrawalStateFailed.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, revenue_withdrawal_state_failed):
|
||||
json_dict = revenue_withdrawal_state_failed.to_dict()
|
||||
assert json_dict == {"type": "failed"}
|
||||
|
|
|
@ -89,7 +89,6 @@ class TestStarTransactionWithoutRequest(StarTransactionTestBase):
|
|||
"receiver": self.receiver.to_dict(),
|
||||
}
|
||||
st = StarTransaction.de_json(json_dict, offline_bot)
|
||||
st_none = StarTransaction.de_json(None, offline_bot)
|
||||
assert st.api_kwargs == {}
|
||||
assert st.id == self.id
|
||||
assert st.amount == self.amount
|
||||
|
@ -97,7 +96,6 @@ class TestStarTransactionWithoutRequest(StarTransactionTestBase):
|
|||
assert st.date == from_timestamp(self.date)
|
||||
assert st.source == self.source
|
||||
assert st.receiver == self.receiver
|
||||
assert st_none is None
|
||||
|
||||
def test_de_json_star_transaction_localization(
|
||||
self, tz_bot, offline_bot, raw_bot, star_transaction
|
||||
|
@ -178,10 +176,8 @@ class TestStarTransactionsWithoutRequest(StarTransactionsTestBase):
|
|||
"transactions": [t.to_dict() for t in self.transactions],
|
||||
}
|
||||
st = StarTransactions.de_json(json_dict, offline_bot)
|
||||
st_none = StarTransactions.de_json(None, offline_bot)
|
||||
assert st.api_kwargs == {}
|
||||
assert st.transactions == tuple(self.transactions)
|
||||
assert st_none is None
|
||||
|
||||
def test_to_dict(self, star_transactions):
|
||||
expected_dict = {
|
||||
|
|
|
@ -114,9 +114,6 @@ class TestTransactionPartnerWithoutRequest(TransactionPartnerTestBase):
|
|||
assert transaction_partner.api_kwargs == {}
|
||||
assert transaction_partner.type == "unknown"
|
||||
|
||||
assert TransactionPartner.de_json(None, offline_bot) is None
|
||||
assert TransactionPartner.de_json({}, offline_bot) is None
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("tp_type", "subclass"),
|
||||
[
|
||||
|
@ -191,9 +188,6 @@ class TestTransactionPartnerAffiliateProgramWithoutRequest(TransactionPartnerTes
|
|||
assert tp.commission_per_mille == self.commission_per_mille
|
||||
assert tp.sponsor_user == self.sponsor_user
|
||||
|
||||
assert TransactionPartnerAffiliateProgram.de_json(None, offline_bot) is None
|
||||
assert TransactionPartnerAffiliateProgram.de_json({}, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, transaction_partner_affiliate_program):
|
||||
json_dict = transaction_partner_affiliate_program.to_dict()
|
||||
assert json_dict["type"] == self.type
|
||||
|
@ -243,8 +237,6 @@ class TestTransactionPartnerFragmentWithoutRequest(TransactionPartnerTestBase):
|
|||
assert tp.type == "fragment"
|
||||
assert tp.withdrawal_state == self.withdrawal_state
|
||||
|
||||
assert TransactionPartnerFragment.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, transaction_partner_fragment):
|
||||
json_dict = transaction_partner_fragment.to_dict()
|
||||
assert json_dict["type"] == self.type
|
||||
|
@ -303,9 +295,6 @@ class TestTransactionPartnerUserWithoutRequest(TransactionPartnerTestBase):
|
|||
assert tp.paid_media_payload == self.paid_media_payload
|
||||
assert tp.subscription_period == self.subscription_period
|
||||
|
||||
assert TransactionPartnerUser.de_json(None, offline_bot) is None
|
||||
assert TransactionPartnerUser.de_json({}, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, transaction_partner_user):
|
||||
json_dict = transaction_partner_user.to_dict()
|
||||
assert json_dict["type"] == self.type
|
||||
|
@ -355,8 +344,6 @@ class TestTransactionPartnerOtherWithoutRequest(TransactionPartnerTestBase):
|
|||
assert tp.api_kwargs == {}
|
||||
assert tp.type == "other"
|
||||
|
||||
assert TransactionPartnerOther.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, transaction_partner_other):
|
||||
json_dict = transaction_partner_other.to_dict()
|
||||
assert json_dict == {"type": self.type}
|
||||
|
@ -397,8 +384,6 @@ class TestTransactionPartnerTelegramAdsWithoutRequest(TransactionPartnerTestBase
|
|||
assert tp.api_kwargs == {}
|
||||
assert tp.type == "telegram_ads"
|
||||
|
||||
assert TransactionPartnerTelegramAds.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, transaction_partner_telegram_ads):
|
||||
json_dict = transaction_partner_telegram_ads.to_dict()
|
||||
assert json_dict == {"type": self.type}
|
||||
|
@ -442,8 +427,6 @@ class TestTransactionPartnerTelegramApiWithoutRequest(TransactionPartnerTestBase
|
|||
assert tp.type == "telegram_api"
|
||||
assert tp.request_count == self.request_count
|
||||
|
||||
assert TransactionPartnerTelegramApi.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, transaction_partner_telegram_api):
|
||||
json_dict = transaction_partner_telegram_api.to_dict()
|
||||
assert json_dict["type"] == self.type
|
||||
|
|
|
@ -37,7 +37,7 @@ from telegram import (
|
|||
User,
|
||||
)
|
||||
from telegram.ext import Defaults
|
||||
from tests.auxil.build_messages import DATE
|
||||
from tests.auxil.build_messages import DATE, make_message
|
||||
from tests.auxil.ci_bots import BOT_INFO_PROVIDER, JOB_INDEX
|
||||
from tests.auxil.constants import PRIVATE_KEY, TEST_TOPIC_ICON_COLOR, TEST_TOPIC_NAME
|
||||
from tests.auxil.envvars import GITHUB_ACTION, RUN_TEST_OFFICIAL, TEST_WITH_OPT_DEPS
|
||||
|
@ -324,3 +324,13 @@ def timezone(tzinfo):
|
|||
@pytest.fixture
|
||||
def tmp_file(tmp_path) -> Path:
|
||||
return tmp_path / uuid4().hex
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def dummy_message():
|
||||
return make_message("dummy_message")
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def dummy_message_dict(dummy_message):
|
||||
return dummy_message.to_dict()
|
||||
|
|
|
@ -43,6 +43,7 @@ from telegram import (
|
|||
Chat,
|
||||
ChatAdministratorRights,
|
||||
ChatFullInfo,
|
||||
ChatInviteLink,
|
||||
ChatPermissions,
|
||||
Dice,
|
||||
InlineKeyboardButton,
|
||||
|
@ -1432,7 +1433,9 @@ class TestBotWithoutRequest:
|
|||
)
|
||||
|
||||
@pytest.mark.parametrize("local_mode", [True, False])
|
||||
async def test_set_chat_photo_local_files(self, monkeypatch, offline_bot, chat_id, local_mode):
|
||||
async def test_set_chat_photo_local_files(
|
||||
self, dummy_message_dict, monkeypatch, offline_bot, chat_id, local_mode
|
||||
):
|
||||
try:
|
||||
offline_bot._local_mode = local_mode
|
||||
# For just test that the correct paths are passed as we have no local Bot API set up
|
||||
|
@ -2228,14 +2231,31 @@ class TestBotWithoutRequest:
|
|||
api_kwargs={"chat_id": 2, "user_id": 32, "until_date": until_timestamp},
|
||||
)
|
||||
|
||||
async def test_business_connection_id_argument(self, offline_bot, monkeypatch):
|
||||
async def test_business_connection_id_argument(
|
||||
self, offline_bot, monkeypatch, dummy_message_dict
|
||||
):
|
||||
"""We can't connect to a business acc, so we just test that the correct data is passed.
|
||||
We also can't test every single method easily, so we just test a few. Our linting will
|
||||
catch any unused args with the others."""
|
||||
return_values = asyncio.Queue()
|
||||
await return_values.put(dummy_message_dict)
|
||||
await return_values.put(
|
||||
Poll(
|
||||
id="42",
|
||||
question="question",
|
||||
options=[PollOption("option", 0)],
|
||||
total_voter_count=5,
|
||||
is_closed=True,
|
||||
is_anonymous=True,
|
||||
type="regular",
|
||||
).to_dict()
|
||||
)
|
||||
await return_values.put(True)
|
||||
await return_values.put(True)
|
||||
|
||||
async def make_assertion(url, request_data: RequestData, *args, **kwargs):
|
||||
assert request_data.parameters.get("business_connection_id") == 42
|
||||
return {}
|
||||
return await return_values.get()
|
||||
|
||||
monkeypatch.setattr(offline_bot.request, "post", make_assertion)
|
||||
|
||||
|
@ -2348,6 +2368,9 @@ class TestBotWithoutRequest:
|
|||
async def make_assertion(url, request_data: RequestData, *args, **kwargs):
|
||||
assert request_data.parameters.get("subscription_period") == 2592000
|
||||
assert request_data.parameters.get("subscription_price") == 6
|
||||
return ChatInviteLink(
|
||||
"https://t.me/joinchat/invite_link", User(1, "first", False), False, False, False
|
||||
).to_dict()
|
||||
|
||||
monkeypatch.setattr(offline_bot.request, "post", make_assertion)
|
||||
|
||||
|
|
|
@ -45,8 +45,6 @@ class TestBotCommandWithoutRequest:
|
|||
assert bot_command.command == self.command
|
||||
assert bot_command.description == self.description
|
||||
|
||||
assert BotCommand.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, bot_command):
|
||||
bot_command_dict = bot_command.to_dict()
|
||||
|
||||
|
|
|
@ -129,8 +129,6 @@ class TestBotCommandScopeWithoutRequest:
|
|||
cls = scope_class_and_type[0]
|
||||
type_ = scope_class_and_type[1]
|
||||
|
||||
assert cls.de_json({}, offline_bot) is None
|
||||
|
||||
json_dict = {"type": type_, "chat_id": chat_id, "user_id": 42}
|
||||
bot_command_scope = BotCommandScope.de_json(json_dict, offline_bot)
|
||||
assert set(bot_command_scope.api_kwargs.keys()) == {"chat_id", "user_id"} - set(
|
||||
|
|
|
@ -170,7 +170,6 @@ class TestBackgroundTypeWithoutRequest:
|
|||
|
||||
def test_de_json_required_args(self, offline_bot, background_type):
|
||||
cls = background_type.__class__
|
||||
assert cls.de_json({}, offline_bot) is None
|
||||
|
||||
json_dict = make_json_dict(background_type)
|
||||
const_background_type = BackgroundType.de_json(json_dict, offline_bot)
|
||||
|
@ -277,7 +276,6 @@ class TestBackgroundFillWithoutRequest:
|
|||
|
||||
def test_de_json_required_args(self, offline_bot, background_fill):
|
||||
cls = background_fill.__class__
|
||||
assert cls.de_json({}, offline_bot) is None
|
||||
|
||||
json_dict = make_json_dict(background_fill)
|
||||
const_background_fill = BackgroundFill.de_json(json_dict, offline_bot)
|
||||
|
|
|
@ -174,8 +174,6 @@ class TestChatBoostSourceTypesWithoutRequest:
|
|||
|
||||
def test_de_json_required_args(self, offline_bot, chat_boost_source):
|
||||
cls = chat_boost_source.__class__
|
||||
assert cls.de_json({}, offline_bot) is None
|
||||
assert ChatBoost.de_json({}, offline_bot) is None
|
||||
|
||||
json_dict = make_json_dict(chat_boost_source)
|
||||
const_boost_source = ChatBoostSource.de_json(json_dict, offline_bot)
|
||||
|
|
|
@ -207,7 +207,6 @@ class TestChatMemberTypesWithoutRequest:
|
|||
|
||||
def test_de_json_required_args(self, offline_bot, chat_member_type):
|
||||
cls = chat_member_type.__class__
|
||||
assert cls.de_json({}, offline_bot) is None
|
||||
|
||||
json_dict = make_json_dict(chat_member_type)
|
||||
const_chat_member = ChatMember.de_json(json_dict, offline_bot)
|
||||
|
|
|
@ -46,7 +46,6 @@ class TestCopyTextButtonWithoutRequest(CopyTextButtonTestBase):
|
|||
assert copy_text_button.api_kwargs == {}
|
||||
|
||||
assert copy_text_button.text == self.text
|
||||
assert CopyTextButton.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, copy_text_button):
|
||||
copy_text_button_dict = copy_text_button.to_dict()
|
||||
|
|
|
@ -46,7 +46,6 @@ class TestDiceWithoutRequest(DiceTestBase):
|
|||
|
||||
assert dice.value == self.value
|
||||
assert dice.emoji == emoji
|
||||
assert Dice.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, dice):
|
||||
dice_dict = dice.to_dict()
|
||||
|
|
|
@ -60,7 +60,6 @@ class TestForumTopicWithoutRequest:
|
|||
assert forum_topic_object.icon_custom_emoji_id == emoji_id
|
||||
|
||||
def test_de_json(self, offline_bot, emoji_id, forum_group_id):
|
||||
assert ForumTopic.de_json(None, bot=offline_bot) is None
|
||||
|
||||
json_dict = {
|
||||
"message_thread_id": forum_group_id,
|
||||
|
@ -307,7 +306,6 @@ class TestForumTopicCreatedWithoutRequest:
|
|||
assert topic_created.name == TEST_TOPIC_NAME
|
||||
|
||||
def test_de_json(self, offline_bot):
|
||||
assert ForumTopicCreated.de_json(None, bot=offline_bot) is None
|
||||
|
||||
json_dict = {"icon_color": TEST_TOPIC_ICON_COLOR, "name": TEST_TOPIC_NAME}
|
||||
action = ForumTopicCreated.de_json(json_dict, offline_bot)
|
||||
|
@ -395,8 +393,6 @@ class TestForumTopicEdited:
|
|||
assert topic_edited.icon_custom_emoji_id == emoji_id
|
||||
|
||||
def test_de_json(self, bot, emoji_id):
|
||||
assert ForumTopicEdited.de_json(None, bot=bot) is None
|
||||
|
||||
json_dict = {"name": TEST_TOPIC_NAME, "icon_custom_emoji_id": emoji_id}
|
||||
action = ForumTopicEdited.de_json(json_dict, bot)
|
||||
assert action.api_kwargs == {}
|
||||
|
|
|
@ -76,8 +76,6 @@ class TestGiftWithoutRequest(GiftTestBase):
|
|||
assert gift.total_count == self.total_count
|
||||
assert gift.remaining_count == self.remaining_count
|
||||
|
||||
assert Gift.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, gift):
|
||||
gift_dict = gift.to_dict()
|
||||
|
||||
|
@ -237,8 +235,6 @@ class TestGiftsWithoutRequest(GiftsTestBase):
|
|||
assert de_json_gift.total_count == original_gift.total_count
|
||||
assert de_json_gift.remaining_count == original_gift.remaining_count
|
||||
|
||||
assert Gifts.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, gifts):
|
||||
gifts_dict = gifts.to_dict()
|
||||
|
||||
|
|
|
@ -94,8 +94,6 @@ class TestGiveawayWithoutRequest:
|
|||
assert giveaway.premium_subscription_month_count == self.premium_subscription_month_count
|
||||
assert giveaway.prize_star_count == self.prize_star_count
|
||||
|
||||
assert Giveaway.de_json(None, offline_bot) is None
|
||||
|
||||
def test_de_json_localization(self, tz_bot, offline_bot, raw_bot):
|
||||
json_dict = {
|
||||
"chats": [chat.to_dict() for chat in self.chats],
|
||||
|
@ -196,8 +194,6 @@ class TestGiveawayCreatedWithoutRequest:
|
|||
assert gac.api_kwargs == {}
|
||||
assert gac.prize_star_count == self.prize_star_count
|
||||
|
||||
assert Giveaway.de_json(None, bot) is None
|
||||
|
||||
def test_to_dict(self, giveaway_created):
|
||||
gac_dict = giveaway_created.to_dict()
|
||||
|
||||
|
@ -281,8 +277,6 @@ class TestGiveawayWinnersWithoutRequest:
|
|||
assert giveaway_winners.prize_description == self.prize_description
|
||||
assert giveaway_winners.prize_star_count == self.prize_star_count
|
||||
|
||||
assert GiveawayWinners.de_json(None, offline_bot) is None
|
||||
|
||||
def test_de_json_localization(self, tz_bot, offline_bot, raw_bot):
|
||||
json_dict = {
|
||||
"chat": self.chat.to_dict(),
|
||||
|
@ -411,8 +405,6 @@ class TestGiveawayCompletedWithoutRequest:
|
|||
assert giveaway_completed.giveaway_message == self.giveaway_message
|
||||
assert giveaway_completed.is_star_giveaway == self.is_star_giveaway
|
||||
|
||||
assert GiveawayCompleted.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, giveaway_completed):
|
||||
giveaway_completed_dict = giveaway_completed.to_dict()
|
||||
|
||||
|
|
|
@ -52,8 +52,6 @@ class TestInlineQueryResultsButtonWithoutRequest(InlineQueryResultsButtonTestBas
|
|||
assert inline_query_results_button_dict["web_app"] == self.web_app.to_dict()
|
||||
|
||||
def test_de_json(self, offline_bot):
|
||||
assert InlineQueryResultsButton.de_json(None, offline_bot) is None
|
||||
assert InlineQueryResultsButton.de_json({}, offline_bot) is None
|
||||
|
||||
json_dict = {
|
||||
"text": self.text,
|
||||
|
|
|
@ -108,9 +108,6 @@ class TestKeyboardButtonWithoutRequest(KeyboardButtonTestBase):
|
|||
assert keyboard_button.request_chat == self.request_chat
|
||||
assert keyboard_button.request_users == self.request_users
|
||||
|
||||
none = KeyboardButton.de_json({}, None)
|
||||
assert none is None
|
||||
|
||||
def test_equality(self):
|
||||
a = KeyboardButton("test", request_contact=True)
|
||||
b = KeyboardButton("test", request_contact=True)
|
||||
|
|
|
@ -179,9 +179,6 @@ class TestKeyboardButtonRequestChatWithoutRequest(KeyboardButtonRequestChatTestB
|
|||
assert request_chat.bot_administrator_rights == self.bot_administrator_rights
|
||||
assert request_chat.bot_is_member == self.bot_is_member
|
||||
|
||||
empty_chat = KeyboardButtonRequestChat.de_json({}, offline_bot)
|
||||
assert empty_chat is None
|
||||
|
||||
def test_equality(self):
|
||||
a = KeyboardButtonRequestChat(self.request_id, True)
|
||||
b = KeyboardButtonRequestChat(self.request_id, True)
|
||||
|
|
|
@ -119,9 +119,6 @@ class TestMenuButtonWithoutRequest(MenuButtonTestBase):
|
|||
if "text" in cls.__slots__:
|
||||
assert menu_button.text == self.text
|
||||
|
||||
assert cls.de_json(None, offline_bot) is None
|
||||
assert MenuButton.de_json({}, offline_bot) is None
|
||||
|
||||
def test_de_json_invalid_type(self, offline_bot):
|
||||
json_dict = {"type": "invalid", "text": self.text, "web_app": self.web_app.to_dict()}
|
||||
menu_button = MenuButton.de_json(json_dict, offline_bot)
|
||||
|
|
|
@ -138,7 +138,6 @@ class TestMessageOriginTypesWithoutRequest:
|
|||
|
||||
def test_de_json_required_args(self, offline_bot, message_origin_type):
|
||||
cls = message_origin_type.__class__
|
||||
assert cls.de_json({}, offline_bot) is None
|
||||
|
||||
json_dict = make_json_dict(message_origin_type)
|
||||
const_message_origin = MessageOrigin.de_json(json_dict, offline_bot)
|
||||
|
|
|
@ -193,9 +193,6 @@ class TestPaidMediaWithoutRequest(PaidMediaTestBase):
|
|||
if "photo" in cls.__slots__:
|
||||
assert pm.photo == self.photo
|
||||
|
||||
assert cls.de_json(None, offline_bot) is None
|
||||
assert PaidMedia.de_json({}, offline_bot) is None
|
||||
|
||||
def test_de_json_invalid_type(self, offline_bot):
|
||||
json_dict = {
|
||||
"type": "invalid",
|
||||
|
@ -308,10 +305,8 @@ class TestPaidMediaInfoWithoutRequest(PaidMediaInfoTestBase):
|
|||
"paid_media": [t.to_dict() for t in self.paid_media],
|
||||
}
|
||||
pmi = PaidMediaInfo.de_json(json_dict, offline_bot)
|
||||
pmi_none = PaidMediaInfo.de_json(None, offline_bot)
|
||||
assert pmi.paid_media == tuple(self.paid_media)
|
||||
assert pmi.star_count == self.star_count
|
||||
assert pmi_none is None
|
||||
|
||||
def test_to_dict(self, paid_media_info):
|
||||
assert paid_media_info.to_dict() == {
|
||||
|
@ -353,11 +348,9 @@ class TestPaidMediaPurchasedWithoutRequest(PaidMediaPurchasedTestBase):
|
|||
"paid_media_payload": self.paid_media_payload,
|
||||
}
|
||||
pmp = PaidMediaPurchased.de_json(json_dict, bot)
|
||||
pmp_none = PaidMediaPurchased.de_json(None, bot)
|
||||
assert pmp.from_user == self.from_user
|
||||
assert pmp.paid_media_payload == self.paid_media_payload
|
||||
assert pmp.api_kwargs == {}
|
||||
assert pmp_none is None
|
||||
|
||||
def test_to_dict(self, paid_media_purchased):
|
||||
assert paid_media_purchased.to_dict() == {
|
||||
|
|
|
@ -54,7 +54,6 @@ class TestInputPollOptionWithoutRequest(InputPollOptionTestBase):
|
|||
), "duplicate slot"
|
||||
|
||||
def test_de_json(self):
|
||||
assert InputPollOption.de_json({}, None) is None
|
||||
|
||||
json_dict = {
|
||||
"text": self.text,
|
||||
|
@ -144,7 +143,7 @@ class TestPollOptionWithoutRequest(PollOptionTestBase):
|
|||
"text_entities": [e.to_dict() for e in self.text_entities],
|
||||
}
|
||||
poll_option = PollOption.de_json(json_dict, None)
|
||||
assert PollOption.de_json(None, None) is None
|
||||
|
||||
assert poll_option.api_kwargs == {}
|
||||
|
||||
assert poll_option.text == self.text
|
||||
|
|
|
@ -117,8 +117,6 @@ class TestReactionTypesWithoutRequest:
|
|||
|
||||
def test_de_json_required_args(self, offline_bot, reaction_type):
|
||||
cls = reaction_type.__class__
|
||||
assert cls.de_json(None, offline_bot) is None
|
||||
assert ReactionType.de_json({}, offline_bot) is None
|
||||
|
||||
json_dict = make_json_dict(reaction_type)
|
||||
const_reaction_type = ReactionType.de_json(json_dict, offline_bot)
|
||||
|
@ -252,8 +250,6 @@ class TestReactionCountWithoutRequest:
|
|||
assert reaction_count.type.emoji == self.type.emoji
|
||||
assert reaction_count.total_count == self.total_count
|
||||
|
||||
assert ReactionCount.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, reaction_count):
|
||||
reaction_count_dict = reaction_count.to_dict()
|
||||
|
||||
|
|
|
@ -93,8 +93,6 @@ class TestExternalReplyInfoWithoutRequest(ExternalReplyInfoTestBase):
|
|||
assert external_reply_info.giveaway == self.giveaway
|
||||
assert external_reply_info.paid_media == self.paid_media
|
||||
|
||||
assert ExternalReplyInfo.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, external_reply_info):
|
||||
ext_reply_info_dict = external_reply_info.to_dict()
|
||||
|
||||
|
@ -167,8 +165,6 @@ class TestTextQuoteWithoutRequest(TextQuoteTestBase):
|
|||
assert text_quote.entities == tuple(self.entities)
|
||||
assert text_quote.is_manual == self.is_manual
|
||||
|
||||
assert TextQuote.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, text_quote):
|
||||
text_quote_dict = text_quote.to_dict()
|
||||
|
||||
|
@ -255,8 +251,6 @@ class TestReplyParametersWithoutRequest(ReplyParametersTestBase):
|
|||
assert reply_parameters.quote_entities == tuple(self.quote_entities)
|
||||
assert reply_parameters.quote_position == self.quote_position
|
||||
|
||||
assert ReplyParameters.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, reply_parameters):
|
||||
reply_parameters_dict = reply_parameters.to_dict()
|
||||
|
||||
|
|
|
@ -59,8 +59,6 @@ class TestUsersSharedWithoutRequest(UsersSharedTestBase):
|
|||
assert users_shared.request_id == self.request_id
|
||||
assert users_shared.users == self.users
|
||||
|
||||
assert UsersShared.de_json({}, offline_bot) is None
|
||||
|
||||
def test_equality(self):
|
||||
a = UsersShared(self.request_id, users=self.users)
|
||||
b = UsersShared(self.request_id, users=self.users)
|
||||
|
@ -209,8 +207,6 @@ class TestSharedUserWithoutRequest(SharedUserTestBase):
|
|||
assert shared_user.username == self.username
|
||||
assert shared_user.photo == self.photo
|
||||
|
||||
assert SharedUser.de_json({}, offline_bot) is None
|
||||
|
||||
def test_equality(self, chat_shared):
|
||||
a = SharedUser(
|
||||
self.user_id,
|
||||
|
|
|
@ -45,7 +45,6 @@ class TestStoryWithoutRequest(StoryTestBase):
|
|||
assert story.chat == self.chat
|
||||
assert story.id == self.id
|
||||
assert isinstance(story, Story)
|
||||
assert Story.de_json(None, offline_bot) is None
|
||||
|
||||
def test_to_dict(self, story):
|
||||
story_dict = story.to_dict()
|
||||
|
|
|
@ -103,7 +103,7 @@ class TestTelegramObject:
|
|||
|
||||
self._id_attrs = (self.arg,)
|
||||
|
||||
assert SubClass.de_list([{"arg": 1}, None, {"arg": 2}, None], bot) == (
|
||||
assert SubClass.de_list([{"arg": 1}, {"arg": 2}], bot) == (
|
||||
SubClass(1),
|
||||
SubClass(2),
|
||||
)
|
||||
|
|
|
@ -252,11 +252,6 @@ class TestUpdateWithoutRequest(UpdateTestBase):
|
|||
assert getattr(update, _type) == paramdict[_type]
|
||||
assert i == 1
|
||||
|
||||
def test_update_de_json_empty(self, offline_bot):
|
||||
update = Update.de_json(None, offline_bot)
|
||||
|
||||
assert update is None
|
||||
|
||||
def test_to_dict(self, update):
|
||||
update_dict = update.to_dict()
|
||||
|
||||
|
|
|
@ -162,7 +162,6 @@ class TestVideoChatScheduledWithoutRequest:
|
|||
assert VideoChatScheduled(self.start_date).start_date == self.start_date
|
||||
|
||||
def test_de_json(self, offline_bot):
|
||||
assert VideoChatScheduled.de_json({}, bot=offline_bot) is None
|
||||
|
||||
json_dict = {"start_date": to_timestamp(self.start_date)}
|
||||
video_chat_scheduled = VideoChatScheduled.de_json(json_dict, offline_bot)
|
||||
|
|
|
@ -99,9 +99,6 @@ class TestWebhookInfoWithoutRequest(WebhookInfoTestBase):
|
|||
self.last_synchronization_error_date
|
||||
)
|
||||
|
||||
none = WebhookInfo.de_json(None, offline_bot)
|
||||
assert none is None
|
||||
|
||||
def test_de_json_localization(self, offline_bot, raw_bot, tz_bot):
|
||||
json_dict = {
|
||||
"url": self.url,
|
||||
|
|
Loading…
Reference in a new issue