Library telemulator3
The free, open-source telemulator3 library designed to simplify automatic testing of Telegram bots created using the pyTelegramBotAPI library.
The telemulator3 library partially emulates the Telegram Bot API in unit tests and allows you to create typical scenarios for the interaction of your bot with the Telegram Bot API.
Installation
pip install telemulator3
Usage
Create TeleBot instance and start emulate Telegram API for bot.
from telebot import TeleBot
from telemulator3 import Telemulator
bot = TeleBot('xxx-yyy-zzz', threaded=False)
@bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
bot.reply_to(message, "Howdy, how are you doing?")
telemul = Telemulator()
telemul.set_tested_bot(bot, username='my_bot', name='My Bot')
At start, there are no registered users in emulated API.
assert not telemul.api.users
Make API user, that represent our bot. It's a first registered user.
mybot = telemul.api.get_me()
assert mybot.is_bot
assert mybot.username == 'my_bot'
assert len(telemul.api.users) == 1
New user open private chat with bot and send /start command.
Bot must answer as defined and his answer must be in chat history.
from telemulator3 import send_command
user = telemul.api.create_user('User')
chat = user.private()
send_command(chat, '/start', user)
assert chat.history.contain('Howdy, how are you doing?')
User create group and add bot as member.
group = user.create_group('My group')
group.add_members(user, [mybot])
assert group.history.contain('invite new members:')
And so on.
mybot.leave(group)
assert group.history.contain('My Bot (ID 1) left chat')
# group.history.dump()
Development
git clone git@github.com:vb64/telemulator3
cd telemulator3
make setup PYTHON_BIN=/path/to/python3
make tests
Metadata
Release files for telemulator3 1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| telemulator3-1.5.tar.gz | 20.3 kB | Without provenance | Details for telemulator3-1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| telemulator3-1.5-py3-none-any.whl | Python 3 | none | any | Details for telemulator3-1.5-py3-none-any.whl |
Total release size: 50.8 kB
Release files / telemulator3-1.5.tar.gz
| Download URL | telemulator3-1.5.tar.gz |
|---|---|
| Size | 20.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
130e40a8ab1ca7f90b631659da306bb6cbfa1d682b664244621a3361dea02f43
|
|
BLAKE2b-256 checksum How to use checksums |
4b28a8f0015f0692beb1e51ee067deeac93c0bc40910393dc02822ac09e28288
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / telemulator3-1.5-py3-none-any.whl
| Download URL | telemulator3-1.5-py3-none-any.whl |
|---|---|
| Size | 30.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fde2e854bc174d6408e26069010238848931c3fb272cb00312dec4ba56b106cd
|
|
BLAKE2b-256 checksum How to use checksums |
1a5b58c2fcc235c8f3d45179bca5645682aefdf8c30693a5aa54bfc58c981957
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for telemulator3 1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.