<commit_before># encoding: utf-8
from os.path import abspath, dirname
from errbot.backends.test import testbot, FullStackTest
from convert import Converter

extra_plugin_dir = dirname(abspath(__name__))


class TestTemperatureConversions(object):
    def test_convert_botcmd(self, testbot):
        testbot.bot.push_message("!convert 1 kilometer to meters")
        assert testbot.bot.pop_message() == "1 kilometer = 1000 meter"
        testbot.bot.push_message("!convert 1 kilometer to yards")
        assert testbot.bot.pop_message() == "1 kilometer = 1093.61 yard"

        testbot.bot.push_message("!convert a kilometer to yards")
        m = testbot.bot.pop_message()
        assert (
            m == "I don't know how to convert that (could not convert string to float: 'a')."
            or m == "I don't know how to convert that (could not convert string to float: a)."
        )
        testbot.bot.push_message("!convert 1 foo to bar")
        assert testbot.bot.pop_message() == "I don't know how to convert that ('foo' is not defined in the unit registry)."

    def test_temperature_regex(self, testbot):
        say_expect = [
            ("It's 30 degrees C", u"30 degC = 86 degF"),
            ("It's 30 degrees Celsius", u"30 degC = 86 degF"),
            ("It's 30 degrees C today", u"30 degC = 86 degF"),
            ("It's 30 degrees c today", u"30 degC = 86 degF"),
            ("It's 30 degrees Celsius today", u"30 degC = 86 degF"),
            ("It's 30 degrees celsius today", u"30 degC = 86 degF"),<commit_msg>PEP8 adherence<commit_after># encoding: utf-8
from os.path import abspath, dirname
from errbot.backends.test import testbot, FullStackTest
from convert import Converter

extra_plugin_dir = dirname(abspath(__name__))


class TestTemperatureConversions(object):
    def test_convert_botcmd(self, testbot):
        testbot.bot.push_message("!convert 1 kilometer to meters")
        assert testbot.bot.pop_message() == "1 kilometer = 1000 meter"
        testbot.bot.push_message("!convert 1 kilometer to yards")
        assert testbot.bot.pop_message() == "1 kilometer = 1093.61 yard"

        testbot.bot.push_message("!convert a kilometer to yards")
        m = testbot.bot.pop_message()
        assert m in (
            "I don't know how to convert that (could not convert string to float: 'a').",
            "I don't know how to convert that (could not convert string to float: a)."
        )
        testbot.bot.push_message("!convert 1 foo to bar")
        assert testbot.bot.pop_message() == \
            "I don't know how to convert that ('foo' is not defined in the unit registry)."

    def test_temperature_regex(self, testbot):
        say_expect = [
            ("It's 30 degrees C", u"30 degC = 86 degF"),
            ("It's 30 degrees Celsius", u"30 degC = 86 degF"),
            ("It's 30 degrees C today", u"30 degC = 86 degF"),
            ("It's 30 degrees c today", u"30 degC = 86 degF"),
            ("It's 30 degrees Celsius today", u"30 degC = 86 degF"),
            ("It's 30 degrees celsius today", u"30 degC = 86 degF"),
{'fraction_non_alphanumeric': 0.11421155094094744, 'fraction_numerical': 0.03406878650227125, 'mean_word_length': 2.773561811505508, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5032403', 'n_tokens_mistral': 1036, 'n_tokens_neox': 921, 'n_words': 325}