def test_create_database(self): dbpath = os.path.join(self.tmpdir, self.DBNAME) max_dist = 2 with FastSS.open(dbpath, 'n', max_dist=max_dist) as fastss: pass with FastSS.open(dbpath, 'r') as fastss: self.assertEqual(fastss.max_dist, max_dist)
def test_add_words(self): dbpath = os.path.join(self.tmpdir, self.DBNAME) words = ('0', '1', '00', '01', '10', '11', '000', '001', '010', '011', '100', '101', '110', '111', '0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111') with FastSS.open(dbpath, 'n') as fastss: for word in words: fastss.add(word) res = fastss.query('1') self.assertEqual(set(res[0]), {'1'}) self.assertEqual(set(res[1]), {'0', '01', '10', '11'}) self.assertEqual( set(res[2]), {'111', '001', '010', '100', '011', '101', '110', '00'})
def test_add_words(self): dbpath = os.path.join(self.tmpdir, self.DBNAME) words = ( '0', '1', '00', '01', '10', '11', '000', '001', '010', '011', '100', '101', '110', '111', '0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111') with FastSS.open(dbpath, 'n') as fastss: for word in words: fastss.add(word) res = fastss.query('1') self.assertEqual(set(res[0]), {'1'}) self.assertEqual(set(res[1]), {'0', '01', '10', '11'}) self.assertEqual(set(res[2]), { '111', '001', '010', '100', '011', '101', '110', '00' })