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
393e6ffc
Commit
393e6ffc
authored
Apr 29, 2013
by
Steve Strassmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added test cases for converter and dummy
parent
c00d71d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
0 deletions
+92
-0
i18n/test/test_converter.py
+42
-0
i18n/test/test_dummy.py
+50
-0
No files found.
i18n/test/test_converter.py
0 → 100644
View file @
393e6ffc
import
os
from
unittest
import
TestCase
import
converter
class
UpcaseConverter
(
converter
.
Converter
):
"""
Converts a string to uppercase. Just used for testing.
"""
def
inner_convert_string
(
self
,
string
):
return
string
.
upper
()
class
TestConverter
(
TestCase
):
"""
Tests functionality of i18n/converter.py
"""
def
test_converter
(
self
):
"""
Tests with a simple converter (converts strings to uppercase).
Assert that embedded HTML and python tags are not converted.
"""
c
=
UpcaseConverter
()
test_cases
=
(
# no tags
(
'big bad wolf'
,
'BIG BAD WOLF'
),
# one html tag
(
'big <strong>bad</strong> wolf'
,
'BIG <strong>BAD</strong> WOLF'
),
# two html tags
(
'big <b>bad</b> <i>wolf</i>'
,
'BIG <b>BAD</b> <i>WOLF</i>'
),
# one python tag
(
'big
%(adjective)
s wolf'
,
'BIG
%(adjective)
s WOLF'
),
# two python tags
(
'big
%(adjective)
s
%(noun)
s'
,
'BIG
%(adjective)
s
%(noun)
s'
),
# both kinds of tags
(
'<strong>big</strong>
%(adjective)
s
%(noun)
s'
,
'<strong>BIG</strong>
%(adjective)
s
%(noun)
s'
),
)
for
(
source
,
expected
)
in
test_cases
:
result
=
c
.
convert
(
source
)
self
.
assertEquals
(
result
,
expected
)
i18n/test/test_dummy.py
0 → 100644
View file @
393e6ffc
import
os
,
string
,
random
from
unittest
import
TestCase
from
polib
import
POEntry
import
dummy
class
TestDummy
(
TestCase
):
"""
Tests functionality of i18n/dummy.py
"""
def
setUp
(
self
):
self
.
converter
=
dummy
.
Dummy
()
def
test_dummy
(
self
):
"""
Tests with a dummy converter (adds spurious accents to strings).
Assert that embedded HTML and python tags are not converted.
"""
test_cases
=
((
"hello my name is Bond, James Bond"
,
u'h
\xe9
ll
\xf6
my n
\xe4
m
\xe9
\xef
s B
\xf6
nd, J
\xe4
m
\xe9
s B
\xf6
nd Lorem i#'
),
(
'don
\'
t convert <a href="href">tag ids</a>'
,
u'd
\xf6
n
\'
t
\xe7\xf6
nv
\xe9
rt <a href="href">t
\xe4
g
\xef
ds</a> Lorem ipsu#'
),
(
'don
\'
t convert
%(name)
s tags on
%(date)
s'
,
u"d
\xf6
n't
\xe7\xf6
nv
\xe9
rt
%(name)
s t
\xe4
gs
\xf6
n
%(date)
s Lorem ips#"
)
)
for
(
source
,
expected
)
in
test_cases
:
result
=
self
.
converter
.
convert
(
source
)
self
.
assertEquals
(
result
,
expected
)
def
test_singular
(
self
):
entry
=
POEntry
()
entry
.
msgid
=
'A lovely day for a cup of tea.'
expected
=
u'
\xc0
l
\xf6
v
\xe9
ly d
\xe4
y f
\xf6
r
\xe4
\xe7\xfc
p
\xf6
f t
\xe9\xe4
. Lorem i#'
self
.
converter
.
convert_msg
(
entry
)
self
.
assertEquals
(
entry
.
msgstr
,
expected
)
def
test_plural
(
self
):
entry
=
POEntry
()
entry
.
msgid
=
'A lovely day for a cup of tea.'
entry
.
msgid_plural
=
'A lovely day for some cups of tea.'
expected_s
=
u'
\xc0
l
\xf6
v
\xe9
ly d
\xe4
y f
\xf6
r
\xe4
\xe7\xfc
p
\xf6
f t
\xe9\xe4
. Lorem i#'
expected_p
=
u'
\xc0
l
\xf6
v
\xe9
ly d
\xe4
y f
\xf6
r s
\xf6
m
\xe9
\xe7\xfc
ps
\xf6
f t
\xe9\xe4
. Lorem ip#'
self
.
converter
.
convert_msg
(
entry
)
result
=
entry
.
msgstr_plural
self
.
assertEquals
(
result
[
'0'
],
expected_s
)
self
.
assertEquals
(
result
[
'1'
],
expected_p
)
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