<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest
import logging
import mock
import os
from multiprocessing import Process
import sys
import time

sys.path.insert(0, os.path.abspath('../..'))

from shellbot import Context, ShellBot
from shellbot.stores import StoreFactory, MemoryStore, SqliteStore

my_bot = ShellBot()


class StoreFactoryTests(unittest.TestCase):

    def test_build_memory(self):

        bot = ShellBot(space=mock.Mock())
        store = StoreFactory.build(bot=bot)
        self.assertTrue(isinstance(store, MemoryStore))

    def test_build_sqlite(self):

        bot = ShellBot(settings={  # from settings to member attributes
                           'sqlite': {
                               'db': 'my_store.db',
                           }
                       },
                       space=mock.Mock())

        store = StoreFactory.build(bot=bot)
        self.assertTrue(isinstance(store, SqliteStore))
        self.assertEqual(bot.context.get('sqlite.db'), 'my_store.db')

    def test_sense(self):

        context = Context(settings={  # default is 'memory'
            'oracle': {<commit_msg>add gc to tests of stores<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest
import gc
import logging
import mock
import os
from multiprocessing import Process
import sys
import time

sys.path.insert(0, os.path.abspath('../..'))

from shellbot import Context, ShellBot
from shellbot.stores import StoreFactory, MemoryStore, SqliteStore

my_bot = ShellBot()


class StoreFactoryTests(unittest.TestCase):

    def tearDown(self):
        collected = gc.collect()
        logging.info("Garbage collector: collected %d objects." % (collected))

    def test_build_memory(self):

        bot = ShellBot(space=mock.Mock())
        store = StoreFactory.build(bot=bot)
        self.assertTrue(isinstance(store, MemoryStore))

    def test_build_sqlite(self):

        bot = ShellBot(settings={  # from settings to member attributes
                           'sqlite': {
                               'db': 'my_store.db',
                           }
                       },
                       space=mock.Mock())

        store = StoreFactory.build(bot=bot)
        self.assertTrue(isinstance(store, SqliteStore))
        self.assertEqual(bot.context.get('sqlite.db'), 'my_store.db')

    def test_sense(self):

        context = Context(settings={  # default is 'memory'
            'oracle': {
{'fraction_non_alphanumeric': 0.11294876966518758, 'fraction_numerical': 0.0016135538523598225, 'mean_word_length': 2.324396782841823, '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': '4864034', 'n_tokens_mistral': 715, 'n_tokens_neox': 690, 'n_words': 161}