Beispiel #1
0
class TestOtama(unittest.TestCase):

    def setUp(self):
        if not os.path.exists(DATA_DIR):
            os.mkdir(DATA_DIR)
        self.otama = Otama()
        self.db = self.otama.open(CONFIG)

    def tearDown(self):
        shutil.rmtree(DATA_DIR)

    def test_open(self):
        o = Otama()
        db = o.open(CONFIG)
        self.assertEqual(type(db), Otama)
        self.assertEqual(True, os.path.exists(DATA_DIR))

    def test_close(self):
        self.assertEqual(None, self.db.close())

    def test_create_database(self):
        self.assertEqual(None, self.db.create_database())

    def test_drop_database(self):
        self.assertEqual(None, self.db.drop_database())

    def test_drop_index(self):
        self.assertEqual(None, self.db.drop_index())

    def test_vacuum_index(self):
        self.assertEqual(None, self.db.vacuum_index())

    def test_has_libotama_version_string(self):
        self.assertEqual(str, type(otama.__libotama_version__))
Beispiel #2
0
class TestOtamaWithLevelDB(unittest.TestCase):

    def setUp(self):
        if not os.path.exists(DATA_DIR):
            os.mkdir(DATA_DIR)
        self.otama = Otama()
        self.db = self.otama.open(INVOKE_CONFIG)

    def tearDown(self):
        shutil.rmtree(DATA_DIR)

    def test_invoke(self):
        # FIXME
        self.assertEqual(None, self.db.invoke('update_idf', 0))
Beispiel #3
0

BASE_DIR = os.path.abspath(os.path.dirname(__file__))
DATA_DIR = os.path.join(BASE_DIR, 'data')
CONFIG_FILE = os.path.join(BASE_DIR, 'test.conf')
IMAGE_DIR = os.path.join(BASE_DIR, 'image')
config = {'namespace': 'testnamespace',
          'driver': {'name': 'color', 'data_dir': DATA_DIR, 'color_weight': 0.2},
          'database': {'driver': 'sqlite3',
                       'name': os.path.join(DATA_DIR, 'store.sqlite3')}
          }

if not os.path.exists(DATA_DIR):
    os.mkdir(DATA_DIR)

#db = Otama.open(CONFIG_FILE)
db = Otama.open(config)
db.create_database()
files = glob(os.path.join(IMAGE_DIR, '*.jpg'))
files += glob(os.path.join(IMAGE_DIR, '*.png'))
kvs = {}
for filename in files:
    kvs[db.insert(filename)] = filename

db.pull()

with open(os.path.join(DATA_DIR, 'kvs.json'), 'w') as fp:
    json.dump(kvs, fp)

db.close()
Beispiel #4
0
 def test_open(self):
     o = Otama()
     db = o.open(CONFIG)
     self.assertEqual(type(db), Otama)
     self.assertEqual(True, os.path.exists(DATA_DIR))