~mvo/software-center/lp1043752

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import time
import unittest
import xapian

from tests.utils import (
    get_test_db,
    get_test_pkg_info,
    setup_test_env,
)
setup_test_env()
from softwarecenter.db.appfilter import AppFilter
from softwarecenter.db.enquire import AppEnquire


class TestEnquire(unittest.TestCase):

    def test_app_enquire(self):
        db = get_test_db()
        cache = get_test_pkg_info()

        xfilter = AppFilter(cache, db)
        enquirer = AppEnquire(cache, db)
        terms = [ "app", "this", "the", "that", "foo", "tool", "game",
                  "graphic", "ubuntu", "debian", "gtk", "this", "bar",
                  "baz"]

        # run a bunch of the querries in parallel
        for nonblocking in [False, True]:
            for i in range(10):
                for term in terms:
                    enquirer.set_query(
                        search_query=xapian.Query(term),
                        limit=0,
                        filter=xfilter,
                        nonblocking_load=nonblocking)
        # give the threads a bit of time
        time.sleep(5)


if __name__ == "__main__":
    unittest.main()