def test_dictionary_from_file(self):
        """Method testing dictionary_from_file method from dota_wiki_parser module.

        The method checks if the imported dictionary from .txt file with JSON content
        is the same as predefined dictionary in the test case.
        """
        resp_dict = {"abc" : "http://def.gh/Abad_a_.mp3", "123" : "http://456.78/Noba_a_.mp3"}
        hero_dict = {"Abad" : "Abaddon", "Noba" : "Techies"}

        self.assertEqual(parser.dictionary_from_file('test_responses_dict.txt'), resp_dict)
        self.assertEqual(parser.dictionary_from_file('test_heroes_dict.txt'), hero_dict)
Пример #2
0
    def test_dictionary_from_file(self):
        """Method testing dictionary_from_file method from dota_wiki_parser module.

        The method checks if the imported dictionary from .txt file with JSON content
        is the same as predefined dictionary in the test case.
        """
        resp_dict = {
            "abc": "http://def.gh/Abad_a_.mp3",
            "123": "http://456.78/Noba_a_.mp3"
        }
        hero_dict = {"Abad": "Abaddon", "Noba": "Techies"}

        self.assertEqual(
            parser.dictionary_from_file('test_responses_dict.txt'), resp_dict)
        self.assertEqual(parser.dictionary_from_file('test_heroes_dict.txt'),
                         hero_dict)
Пример #3
0
    def test_ellipsis_to_three_dots(self):
        """Method testing ellipsis_to_three_dots method from dota_wiki_parser module."""
        in_dict = parser.dictionary_from_file('test_ellipsis_dict.txt')
        out_dict = {'aa...aa': 'abc', '...': 'aaa', '1... 2... 3...': '123'}

        self.assertEqual(parser.ellipsis_to_three_dots(in_dict), out_dict)
    def test_ellipsis_to_three_dots(self):
        """Method testing ellipsis_to_three_dots method from dota_wiki_parser module."""
        in_dict = parser.dictionary_from_file('test_ellipsis_dict.txt')
        out_dict = {'aa...aa' : 'abc', '...' : 'aaa', '1... 2... 3...' : '123'}

        self.assertEqual(parser.ellipsis_to_three_dots(in_dict), out_dict)
Пример #5
0
import re
import os

from telegram import InlineQueryResultArticle, ParseMode, \
    InputTextMessageContent
from telegram import InlineQueryResultAudio
from telegram.ext import Updater, InlineQueryHandler, CommandHandler
import logging
import sqlite3

import dota_wiki_parser as parser
import properties

SCRIPT_DIR = os.path.dirname(__file__)
heroes_dict = parser.dictionary_from_file("heroes.json")


# Enable logging
logging.basicConfig(
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        level=logging.INFO)

logger = logging.getLogger(__name__)


# Define a few command handlers. These usually take the two arguments bot and
# update. Error handlers also receive the raised TelegramError object in error.
def start(bot, update):
    bot.sendMessage(update.message.chat_id, text='Hi!')