Esempio n. 1
0
    def test_quote_suffix(self):
        dbPath = os.path.join(testPath, '__test_bot_quote_suffix.sqlite')
        self._delete(dbPath)

        settings = Settings()
        settings.QUOTE_AUTO_SUFFIX = True

        now = datetime.now()
        expected_suffix = " - {streamer} @ {year}-{month:02}-{day:02}".format(
            streamer=settings.CHANNEL_LIST["#tmp"],
            year=int(now.strftime("%Y")),
            month=int(now.strftime("%m")),
            day=int(now.strftime("%d")))

        bot = Bot(settings,
                  None,
                  FakeWrapper,
                  logger=nullLogger,
                  wrap_irc=False)
        bot._initialize_models()
        bot._add_quote("#tmp", "foobar", ["test"], timestamp=now)
        quote_id, quote = bot._get_model("#tmp", "quotes").get_random_quote()

        expected = "test" + expected_suffix

        assert quote == expected
Esempio n. 2
0
    def test_get_random_quote(self):
        dbPath = os.path.join(testPath, '__test_bot_get_random_quote.sqlite')
        self._delete(dbPath)

        settings = Settings()
        settings.DATABASE_PATH = dbPath

        bot = Bot(settings, None, FakeWrapper, logger=nullLogger,
                  wrap_irc=False)
        bot._initialize_models()
        quote_id, quote = bot._get_model("#tmp", "quotes").get_random_quote()

        assert quote_id is None
        assert quote is None
Esempio n. 3
0
    def test_get_random_quote(self):
        dbPath = os.path.join(testPath, '__test_bot_get_random_quote.sqlite')
        self._delete(dbPath)

        settings = Settings()
        settings.DATABASE_PATH = dbPath

        bot = Bot(settings,
                  None,
                  FakeWrapper,
                  logger=nullLogger,
                  wrap_irc=False)
        bot._initialize_models()
        quote_id, quote = bot._get_model("#tmp", "quotes").get_random_quote()

        assert quote_id is None
        assert quote is None
Esempio n. 4
0
    def test__del_quote(self):
        dbPath = os.path.join(testPath, '__test_bot_del_quote.sqlite')
        self._delete(dbPath)

        settings = Settings()
        settings.DATABASE_PATH = dbPath

        bot = Bot(settings, None, FakeWrapper, logger=nullLogger,
                  wrap_irc=False)
        bot._initialize_models()
        bot._add_quote("#tmp", "foobar", ["test"])
        bot._add_quote("#tmp", "foobar", ["test2"])
        bot._del_quote("#tmp", "foobar", [1])

        quote_id, quote = bot._get_model("#tmp", "quotes").get_random_quote()

        assert str(quote) == "test2"
Esempio n. 5
0
    def test__del_quote(self):
        dbPath = os.path.join(testPath, '__test_bot_del_quote.sqlite')
        self._delete(dbPath)

        settings = Settings()
        settings.DATABASE_PATH = dbPath

        bot = Bot(settings,
                  None,
                  FakeWrapper,
                  logger=nullLogger,
                  wrap_irc=False)
        bot._initialize_models()
        bot._add_quote("#tmp", "foobar", ["test"])
        bot._add_quote("#tmp", "foobar", ["test2"])
        bot._del_quote("#tmp", "foobar", [1])

        quote_id, quote = bot._get_model("#tmp", "quotes").get_random_quote()

        assert str(quote) == "test2"
Esempio n. 6
0
    def test_quote_suffix(self):
        dbPath = os.path.join(testPath, '__test_bot_quote_suffix.sqlite')
        self._delete(dbPath)

        settings = Settings()
        settings.QUOTE_AUTO_SUFFIX = True

        now = datetime.now()
        expected_suffix = " - {streamer} @ {year}-{month:02}-{day:02}".format(
            streamer=settings.CHANNEL_LIST["#tmp"],
            year=int(now.strftime("%Y")),
            month=int(now.strftime("%m")),
            day=int(now.strftime("%d"))
        )

        bot = Bot(settings, None, FakeWrapper, logger=nullLogger,
                  wrap_irc=False)
        bot._initialize_models()
        bot._add_quote("#tmp", "foobar", ["test"], timestamp=now)
        quote_id, quote = bot._get_model("#tmp", "quotes").get_random_quote()

        expected = "test" + expected_suffix

        assert quote == expected