def test_track(self): """Test sending event to botan""" print('Test sending event to botan') botan = Botan(self.token) message = MessageMock(self._chat_id) result = botan.track(message, 'named event') self.assertTrue(result)
def test_wrong_endpoint(self): """Test wrong endpoint""" print('Test wrong endpoint') botan = Botan(self.token) botan.url_template = 'https://api.botaaaaan.io/traccc?token={token}&uid={uid}&name={name}' message = MessageMock(self._chat_id) result = botan.track(message, 'named event') self.assertFalse(result)
def test_wrong_message(self): """Test sending wrong message""" print('Test sending wrong message') botan = Botan(self.token) message = MessageMock(self._chat_id) message = delattr(message, 'chat_id') result = botan.track(message, 'named event') self.assertFalse(result)
def test_track_fail(self): """Test fail when sending event to botan""" print('Test fail when sending event to botan') botan = Botan(self.token) botan.url_template = 'https://api.botan.io/traccc?token={token}&uid={uid}&name={name}' message = MessageMock(self._chat_id) result = botan.track(message, 'named event') self.assertFalse(result)
def __init__(self, telegram, botan=None): if botan: from telegram.utils.botan import Botan self.__botan = Botan(botan) self.__updater = Updater(telegram) dp = self.__updater.dispatcher dp.addTelegramCommandHandler('start', self.__start) dp.addTelegramCommandHandler('help', self.__help) dp.addTelegramCommandHandler('about', self.__about) dp.addTelegramCommandHandler('today', self.__today) dp.addTelegramCommandHandler('week', self.__week) dp.addTelegramCommandHandler('month', self.__month) dp.addUnknownTelegramCommandHandler(self.__unknow) dp.addErrorHandler(self.__error)
db.bind('sqlite', DB_NAME, create_db=True) db.generate_mapping(create_tables=True) with db_session: if len(select(a for a in Admin if a.id is 10049375)) is 0: # Create initial admin account Admin(id=10049375, first_name="Jannes", super_admin=True) if len(select(a for a in Admin if a.id is 46348706)) is 0: # Create initial admin account Admin(id=46348706, first_name="Jackson", super_admin=True) # pass botan = False if BOTAN_TOKEN: botan = Botan(BOTAN_TOKEN) help_text = "This bot keeps a database of known trustworthy bitcoin traders by recording " \ "their phone number, bank account number and name.\n\n" \ "<b>Usage:</b>\n" \ "/search - Search the database for reports\n\n" \ "Donations via BTC are welcome: 1EPu17mBM2zw4LcupURgwsAuFeKQrTa1jy" admin_help_text = "\n\n" \ "<b>Admin commands:</b>\n" \ "/new - Add a new trusted trader\n" \ "/edit - Edit an existing trusted trader\n" \ "/delete - Delete a trusted trader\n" \ "/cancel - Cancel current operation" super_admin_help_text = "\n\n" \
def test_wrong_message(self): botan = Botan(self.token) message = MessageMock(self._chat_id) message = delattr(message, 'chat_id') result = botan.track(message, 'named event') self.assertFalse(result)
def test_track(self): botan = Botan(self.token) message = MessageMock(self._chat_id) result = botan.track(message, 'named event') self.assertTrue(result)
def __init__(self, updater, database, botan_token=''): self.updater = updater if botan_token: self.botan = Botan(botan_token) self.__db = database