Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Pootle-1.2.1/Pootle/test_indexing.py
blob: 6c4d57b0b47b9717981d960bb7d007b529e6762a (plain)
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
# -*- coding: utf-8 -*-
from Pootle import pootle
from Pootle import pootlefile

def setup_module(module):
    """initialize global variables in the module"""
    parser = pootle.PootleOptionParser()
    options, args = parser.parse_args(["--servertype=dummy"])
    module.server = parser.getserver(options)
    # shortcuts to make tests easier
    module.potree = module.server.potree

def test_init():
    """tests that the index can be initialized"""
    for languagecode, languagename in potree.getlanguages("pootle"):
       translationproject = potree.getproject(languagecode, "pootle")
       assert translationproject.make_indexer()

def test_search():
    """tests that the index can be initialized"""
    pass_search = pootlefile.Search(searchtext="login")
    fail_search = pootlefile.Search(searchtext="Zrogny")
    for languagecode, languagename in potree.getlanguages("pootle"):
       translationproject = potree.getproject(languagecode, "pootle")
       print translationproject.make_indexer().location
       pass_search_results = translationproject.searchpoitems("pootle.po", -1, pass_search)
       pass_search_results = [(pofilename, item) for pofilename, item in pass_search_results]
       assert pass_search_results
       fail_search_results = translationproject.searchpoitems("pootle.po", -1, fail_search)
       fail_search_results = [(pofilename, item) for pofilename, item in fail_search_results]
       assert not fail_search_results