Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
8acca44e
Commit
8acca44e
authored
Jan 26, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test database index migrations
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
7b5759be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
weblate/trans/tests/test_search.py
weblate/trans/tests/test_search.py
+62
-0
No files found.
weblate/trans/tests/test_search.py
View file @
8acca44e
...
...
@@ -23,10 +23,16 @@ Tests for search views.
"""
import
re
import
shutil
import
tempfile
from
unittest
import
TestCase
from
whoosh.filedb.filestore
import
FileStorage
from
whoosh.fields
import
Schema
,
ID
,
TEXT
from
django.core.urlresolvers
import
reverse
from
weblate.trans.tests.test_views
import
ViewTestCase
from
weblate.trans.tests
import
OverrideSettings
from
weblate.trans.search
import
update_index_unit
import
weblate.trans.search
from
weblate.trans.models
import
IndexUpdate
...
...
@@ -375,3 +381,59 @@ class SearchBackendTest(ViewTestCase):
self
.
assertEqual
(
IndexUpdate
.
objects
.
count
(),
1
)
update
=
IndexUpdate
.
objects
.
all
()[
0
]
self
.
assertTrue
(
update
.
source
,
True
)
class
SearchMigrationTest
(
TestCase
):
"""Search index migration testing"""
def
setUp
(
self
):
self
.
path
=
tempfile
.
mkdtemp
()
self
.
backup
=
weblate
.
trans
.
search
.
STORAGE
self
.
storage
=
FileStorage
(
self
.
path
)
weblate
.
trans
.
search
.
STORAGE
=
self
.
storage
self
.
storage
.
create
()
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
path
)
weblate
.
trans
.
search
.
STORAGE
=
self
.
backup
def
do_test
(
self
,
source
,
target
):
self
.
storage
.
create_index
(
source
,
'source'
)
self
.
storage
.
create_index
(
target
,
'target-cs'
)
self
.
assertIsNotNone
(
weblate
.
trans
.
search
.
get_source_index
()
)
self
.
assertIsNotNone
(
weblate
.
trans
.
search
.
get_target_index
(
'cs'
)
)
def
test_current
(
self
):
source
=
weblate
.
trans
.
search
.
SourceSchema
target
=
weblate
.
trans
.
search
.
TargetSchema
self
.
do_test
(
source
,
target
)
def
test_2_4
(
self
):
source
=
Schema
(
checksum
=
ID
(
stored
=
True
,
unique
=
True
),
source
=
TEXT
(),
context
=
TEXT
(),
location
=
TEXT
()
)
target
=
Schema
(
checksum
=
ID
(
stored
=
True
,
unique
=
True
),
target
=
TEXT
(),
comment
=
TEXT
(),
)
self
.
do_test
(
source
,
target
)
def
test_2_1
(
self
):
source
=
Schema
(
checksum
=
ID
(
stored
=
True
,
unique
=
True
),
source
=
TEXT
(),
context
=
TEXT
(),
)
target
=
Schema
(
checksum
=
ID
(
stored
=
True
,
unique
=
True
),
target
=
TEXT
(),
)
self
.
do_test
(
source
,
target
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment