Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
ae697de7
Commit
ae697de7
authored
Sep 03, 2014
by
Sarina Canelake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add i18n extraction test
parent
08a0c639
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
common/lib/i18n/tests/__init__.py
+0
-0
common/lib/i18n/tests/test_extract_and_generate.py
+15
-11
No files found.
common/lib/i18n/tests/__init__.py
0 → 100644
View file @
ae697de7
common/lib/
test
_generate.py
→
common/lib/
i18n/tests/test_extract_and
_generate.py
View file @
ae697de7
...
...
@@ -10,10 +10,10 @@ from mock import patch
from
polib
import
pofile
from
pytz
import
UTC
from
i18n
import
config
from
i18n
import
extract
from
i18n
import
generate
from
i18n
import
dummy
from
i18n.config
import
CONFIGURATION
class
TestGenerate
(
TestCase
):
...
...
@@ -24,15 +24,19 @@ class TestGenerate(TestCase):
@classmethod
def
setUpClass
(
cls
):
cfg
=
os
.
path
.
join
(
'conf'
,
'locale'
,
'config.yaml'
)
config
.
CONFIGURATION
=
config
.
Configuration
(
cfg
)
sys
.
stderr
.
write
(
"
\n
This test tests that i18n extraction (`paver i18n_extract`) works properly. "
"If you experience failures, please check that all instances of `gettext` and "
"`ngettext` are used correctly. You can also try running `paver i18n_extract -v` "
"locally for more detail.
\n
"
)
sys
.
stderr
.
write
(
"
\n
Extracting i18n strings and generating dummy translations; "
"this may take a few minutes
\n
"
)
sys
.
stderr
.
flush
()
extract
.
main
(
verbosity
=
0
,
config
=
cfg
)
dummy
.
main
(
verbosity
=
0
,
config
=
cfg
)
extract
.
main
(
verbosity
=
0
)
dummy
.
main
(
verbosity
=
0
)
def
setUp
(
self
):
# Subtract 1 second to help comparisons with file-modify time succeed,
...
...
@@ -43,13 +47,13 @@ class TestGenerate(TestCase):
"""
Tests merge script on English source files.
"""
filename
=
os
.
path
.
join
(
config
.
CONFIGURATION
.
source_messages_dir
,
random_name
())
generate
.
merge
(
config
.
CONFIGURATION
.
source_locale
,
target
=
filename
)
filename
=
os
.
path
.
join
(
CONFIGURATION
.
source_messages_dir
,
random_name
())
generate
.
merge
(
CONFIGURATION
.
source_locale
,
target
=
filename
)
self
.
assertTrue
(
os
.
path
.
exists
(
filename
))
os
.
remove
(
filename
)
# Patch dummy_locales to not have esperanto present
@patch.object
(
config
.
CONFIGURATION
,
'dummy_locales'
,
[
'fake2'
])
@patch.object
(
CONFIGURATION
,
'dummy_locales'
,
[
'fake2'
])
def
test_main
(
self
):
"""
Runs generate.main() which should merge source files,
...
...
@@ -59,10 +63,10 @@ class TestGenerate(TestCase):
after start of test suite)
"""
generate
.
main
(
verbosity
=
0
,
strict
=
False
)
for
locale
in
config
.
CONFIGURATION
.
translated_locales
:
for
locale
in
CONFIGURATION
.
translated_locales
:
for
filename
in
(
'django'
,
'djangojs'
):
mofile
=
filename
+
'.mo'
path
=
os
.
path
.
join
(
config
.
CONFIGURATION
.
get_messages_dir
(
locale
),
mofile
)
path
=
os
.
path
.
join
(
CONFIGURATION
.
get_messages_dir
(
locale
),
mofile
)
exists
=
os
.
path
.
exists
(
path
)
self
.
assertTrue
(
exists
,
msg
=
'Missing file in locale
%
s:
%
s'
%
(
locale
,
mofile
))
self
.
assertTrue
(
datetime
.
fromtimestamp
(
os
.
path
.
getmtime
(
path
),
UTC
)
>=
self
.
start_time
,
...
...
@@ -83,7 +87,7 @@ class TestGenerate(TestCase):
# #-#-#-#-# django-partial.po (0.1a) #-#-#-#-#
"""
path
=
os
.
path
.
join
(
config
.
CONFIGURATION
.
get_messages_dir
(
locale
),
'django.po'
)
path
=
os
.
path
.
join
(
CONFIGURATION
.
get_messages_dir
(
locale
),
'django.po'
)
po
=
pofile
(
path
)
pattern
=
re
.
compile
(
'^#-#-#-#-#'
,
re
.
M
)
match
=
pattern
.
findall
(
po
.
header
)
...
...
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