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
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
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"
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