예제 #1
0
    def test_set_default_city(self, config, bot, update):
        city = "Moscow"

        wset(config, bot, update, [city])
        weather(config, bot, update, [])

        assert city in bot.get_message()
예제 #2
0
    def test_default_city_for_all(self, config, bot, update):
        expected_answer = "Syktyvkar"
        update.set_message(message="", username="******")

        weather(config, bot, update, [])

        assert expected_answer in bot.get_message()
예제 #3
0
    def test_fake_city(self, config, bot, update):
        city = "FakeCity_13"
        expected_answer = "The searched item was not found."

        weather(config, bot, update, [city])

        assert expected_answer in bot.get_message()
예제 #4
0
async def weather_parser(config, bot, update):
    in_text = prepare_message(update)

    with connector(config.engine()) as ses:
        try:
            phrase = "".join(
                ses.query(WeatherPhrases.match).filter(
                    literal(in_text.lower()).contains(
                        WeatherPhrases.match)).one())
            weather(
                config, bot, update,
                in_text.lower()[in_text.lower().find(phrase) +
                                len(phrase):].split())
            return
        except NoResultFound:
            pass
예제 #5
0
    def test_default_city_for_user(self, config, bot, update):
        expected_answer = "London"

        weather(config, bot, update, [])

        assert expected_answer in bot.get_message()
예제 #6
0
    def test_real_city(self, config, bot, update):
        city = 'Moscow'

        weather(config, bot, update, [city])

        assert city in bot.get_message()