Esempio n. 1
0
    def test_repeated_values(self):
        index = TableIndex("unit_test")
        one = Atom("foo", "the")
        two = Atom("bar", "the")
        index.write(one)
        index.write(two)

        self.assertEqual(index.query("the"), [one, two])
Esempio n. 2
0
    def test_overlapping_atoms(self):
        index = TableIndex("unit_test")
        the = Atom("the", "the")
        the_way = Atom("the", "the way")
        index.write(the)
        index.write(the_way)

        self.assertEqual(index.query("the"), [the])
        self.assertEqual(index.query("the way"), [the, the_way])
        self.assertEqual(index.query("way"), [])
Esempio n. 3
0
 def test_one_atom(self):
     index = TableIndex("unit_test")
     atom = Atom("foo", "bar")
     index.write(atom)
     self.assertEqual(index.query(""), [])
     self.assertEqual(index.query("foo"), [])
     self.assertEqual(index.query("bar"), [atom])
     self.assertEqual(index.query("Bar"), [atom])
     self.assertEqual(index.all(), [atom])
Esempio n. 4
0
    def test_many_atoms(self):
        index = TableIndex("unit_test")
        foo = Atom("foo", "foo")
        bar = Atom("bar", "bar")
        baz = Atom("baz", "baz")
        index.write(foo)
        index.write(bar)
        index.write(baz)

        all = index.all()
        self.assertEqual(len(all), 3)
        self.assertTrue(foo in all)
        self.assertTrue(bar in all)
        self.assertTrue(baz in all)

        self.assertEqual(index.query("foo"), [foo])
        self.assertEqual(index.query("bar"), [bar])
        self.assertEqual(index.query("baz"), [baz])

        self.assertEqual(index.query("foo bar"), [foo, bar])
        self.assertEqual(index.query("baz bar foo"), [baz, bar, foo])
Esempio n. 5
0
 def test_empty(self):
     index = TableIndex("unit_test")
     self.assertEqual(index.query(""), [])
     self.assertEqual(index.query("foo"), [])
     self.assertEqual(index.all(), [])