1 # -*- coding: utf-8 -*-
2 from Pootle
import pootle
3 from Pootle
import pootlefile
5 def setup_module(module
):
6 """initialize global variables in the module"""
7 parser
= pootle
.PootleOptionParser()
8 options
, args
= parser
.parse_args(["--servertype=dummy"])
9 module
.server
= parser
.getserver(options
)
10 # shortcuts to make tests easier
11 module
.potree
= module
.server
.potree
14 """tests that the index can be initialized"""
15 for languagecode
, languagename
in potree
.getlanguages("pootle"):
16 translationproject
= potree
.getproject(languagecode
, "pootle")
17 assert hasattr(translationproject
, "indexdir")
20 """tests that the index can be initialized"""
21 pass_search
= pootlefile
.Search(searchtext
="login")
22 fail_search
= pootlefile
.Search(searchtext
="Zrogny")
23 for languagecode
, languagename
in potree
.getlanguages("pootle"):
24 translationproject
= potree
.getproject(languagecode
, "pootle")
25 print translationproject
.indexdir
26 pass_search_results
= translationproject
.searchpoitems("pootle.po", -1, pass_search
)
27 pass_search_results
= [(pofilename
, item
) for pofilename
, item
in pass_search_results
]
28 assert pass_search_results
29 fail_search_results
= translationproject
.searchpoitems("pootle.po", -1, fail_search
)
30 fail_search_results
= [(pofilename
, item
) for pofilename
, item
in fail_search_results
]
31 assert not fail_search_results