Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
0697bb22
Commit
0697bb22
authored
8 years ago
by
Johannes Löthberg
Browse files
Options
Downloads
Patches
Plain Diff
Make test_preview use unicode strings
Signed-off-by:
Johannes Löthberg
<
johannes@kyriasis.com
>
parent
24081224
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_preview.py
+68
-68
68 additions, 68 deletions
tests/test_preview.py
with
68 additions
and
68 deletions
tests/test_preview.py
+
68
−
68
View file @
0697bb22
...
@@ -24,7 +24,7 @@ class PreviewTestCase(unittest.TestCase):
...
@@ -24,7 +24,7 @@ class PreviewTestCase(unittest.TestCase):
def
test_long_summarize
(
self
):
def
test_long_summarize
(
self
):
example_paras
=
[
example_paras
=
[
"""
Tromsø (Norwegian pronunciation: [ˈtrʊmsœ] ( listen); Northern Sami:
u
"""
Tromsø (Norwegian pronunciation: [ˈtrʊmsœ] ( listen); Northern Sami:
Romsa; Finnish: Tromssa[2] Kven: Tromssa) is a city and municipality in
Romsa; Finnish: Tromssa[2] Kven: Tromssa) is a city and municipality in
Troms county, Norway. The administrative centre of the municipality is
Troms county, Norway. The administrative centre of the municipality is
the city of Tromsø. Outside of Norway, Tromso and Tromsö are
the city of Tromsø. Outside of Norway, Tromso and Tromsö are
...
@@ -32,7 +32,7 @@ class PreviewTestCase(unittest.TestCase):
...
@@ -32,7 +32,7 @@ class PreviewTestCase(unittest.TestCase):
city in the world with a population above 50,000. The most populous town
city in the world with a population above 50,000. The most populous town
north of it is Alta, Norway, with a population of 14,272 (2013).
"""
,
north of it is Alta, Norway, with a population of 14,272 (2013).
"""
,
"""
Tromsø lies in Northern Norway. The municipality has a population of
u
"""
Tromsø lies in Northern Norway. The municipality has a population of
(2015) 72,066, but with an annual influx of students it has over 75,000
(2015) 72,066, but with an annual influx of students it has over 75,000
most of the year. It is the largest urban area in Northern Norway and the
most of the year. It is the largest urban area in Northern Norway and the
third largest north of the Arctic Circle (following Murmansk and Norilsk).
third largest north of the Arctic Circle (following Murmansk and Norilsk).
...
@@ -46,7 +46,7 @@ class PreviewTestCase(unittest.TestCase):
...
@@ -46,7 +46,7 @@ class PreviewTestCase(unittest.TestCase):
in Europe. The city is warmer than most other places located on the same
in Europe. The city is warmer than most other places located on the same
latitude, due to the warming effect of the Gulf Stream.
"""
,
latitude, due to the warming effect of the Gulf Stream.
"""
,
"""
The city centre of Tromsø contains the highest number of old wooden
u
"""
The city centre of Tromsø contains the highest number of old wooden
houses in Northern Norway, the oldest house dating from 1789. The Arctic
houses in Northern Norway, the oldest house dating from 1789. The Arctic
Cathedral, a modern church from 1965, is probably the most famous landmark
Cathedral, a modern church from 1965, is probably the most famous landmark
in Tromsø. The city is a cultural centre for its region, with several
in Tromsø. The city is a cultural centre for its region, with several
...
@@ -60,90 +60,90 @@ class PreviewTestCase(unittest.TestCase):
...
@@ -60,90 +60,90 @@ class PreviewTestCase(unittest.TestCase):
self
.
assertEquals
(
self
.
assertEquals
(
desc
,
desc
,
"
Tromsø (Norwegian pronunciation: [ˈtrʊmsœ] ( listen); Northern Sami:
"
u
"
Tromsø (Norwegian pronunciation: [ˈtrʊmsœ] ( listen); Northern Sami:
"
"
Romsa; Finnish: Tromssa[2] Kven: Tromssa) is a city and municipality in
"
u
"
Romsa; Finnish: Tromssa[2] Kven: Tromssa) is a city and municipality in
"
"
Troms county, Norway. The administrative centre of the municipality is
"
u
"
Troms county, Norway. The administrative centre of the municipality is
"
"
the city of Tromsø. Outside of Norway, Tromso and Tromsö are
"
u
"
the city of Tromsø. Outside of Norway, Tromso and Tromsö are
"
"
alternative spellings of the city.Tromsø is considered the northernmost
"
u
"
alternative spellings of the city.Tromsø is considered the northernmost
"
"
city in the world with a population above 50,000. The most populous town
"
u
"
city in the world with a population above 50,000. The most populous town
"
"
north of it is Alta, Norway, with a population of 14,272 (2013).
"
u
"
north of it is Alta, Norway, with a population of 14,272 (2013).
"
)
)
desc
=
summarize_paragraphs
(
example_paras
[
1
:],
min_size
=
200
,
max_size
=
500
)
desc
=
summarize_paragraphs
(
example_paras
[
1
:],
min_size
=
200
,
max_size
=
500
)
self
.
assertEquals
(
self
.
assertEquals
(
desc
,
desc
,
"
Tromsø lies in Northern Norway. The municipality has a population of
"
u
"
Tromsø lies in Northern Norway. The municipality has a population of
"
"
(2015) 72,066, but with an annual influx of students it has over 75,000
"
u
"
(2015) 72,066, but with an annual influx of students it has over 75,000
"
"
most of the year. It is the largest urban area in Northern Norway and the
"
u
"
most of the year. It is the largest urban area in Northern Norway and the
"
"
third largest north of the Arctic Circle (following Murmansk and Norilsk).
"
u
"
third largest north of the Arctic Circle (following Murmansk and Norilsk).
"
"
Most of Tromsø, including the city centre, is located on the island of
"
u
"
Most of Tromsø, including the city centre, is located on the island of
"
"
Tromsøya, 350 kilometres (217 mi) north of the Arctic Circle. In 2012,
"
u
"
Tromsøya, 350 kilometres (217 mi) north of the Arctic Circle. In 2012,
"
"
Tromsøya had a population of 36,088. Substantial parts of the…
"
u
"
Tromsøya had a population of 36,088. Substantial parts of the…
"
)
)
def
test_short_summarize
(
self
):
def
test_short_summarize
(
self
):
example_paras
=
[
example_paras
=
[
"
Tromsø (Norwegian pronunciation: [ˈtrʊmsœ] ( listen); Northern Sami:
"
u
"
Tromsø (Norwegian pronunciation: [ˈtrʊmsœ] ( listen); Northern Sami:
"
"
Romsa; Finnish: Tromssa[2] Kven: Tromssa) is a city and municipality in
"
u
"
Romsa; Finnish: Tromssa[2] Kven: Tromssa) is a city and municipality in
"
"
Troms county, Norway.
"
,
u
"
Troms county, Norway.
"
,
"
Tromsø lies in Northern Norway. The municipality has a population of
"
u
"
Tromsø lies in Northern Norway. The municipality has a population of
"
"
(2015) 72,066, but with an annual influx of students it has over 75,000
"
u
"
(2015) 72,066, but with an annual influx of students it has over 75,000
"
"
most of the year.
"
,
u
"
most of the year.
"
,
"
The city centre of Tromsø contains the highest number of old wooden
"
u
"
The city centre of Tromsø contains the highest number of old wooden
"
"
houses in Northern Norway, the oldest house dating from 1789. The Arctic
"
u
"
houses in Northern Norway, the oldest house dating from 1789. The Arctic
"
"
Cathedral, a modern church from 1965, is probably the most famous landmark
"
u
"
Cathedral, a modern church from 1965, is probably the most famous landmark
"
"
in Tromsø.
"
,
u
"
in Tromsø.
"
,
]
]
desc
=
summarize_paragraphs
(
example_paras
,
min_size
=
200
,
max_size
=
500
)
desc
=
summarize_paragraphs
(
example_paras
,
min_size
=
200
,
max_size
=
500
)
self
.
assertEquals
(
self
.
assertEquals
(
desc
,
desc
,
"
Tromsø (Norwegian pronunciation: [ˈtrʊmsœ] ( listen); Northern Sami:
"
u
"
Tromsø (Norwegian pronunciation: [ˈtrʊmsœ] ( listen); Northern Sami:
"
"
Romsa; Finnish: Tromssa[2] Kven: Tromssa) is a city and municipality in
"
u
"
Romsa; Finnish: Tromssa[2] Kven: Tromssa) is a city and municipality in
"
"
Troms county, Norway.
\n
"
u
"
Troms county, Norway.
\n
"
"
\n
"
u
"
\n
"
"
Tromsø lies in Northern Norway. The municipality has a population of
"
u
"
Tromsø lies in Northern Norway. The municipality has a population of
"
"
(2015) 72,066, but with an annual influx of students it has over 75,000
"
u
"
(2015) 72,066, but with an annual influx of students it has over 75,000
"
"
most of the year.
"
u
"
most of the year.
"
)
)
def
test_small_then_large_summarize
(
self
):
def
test_small_then_large_summarize
(
self
):
example_paras
=
[
example_paras
=
[
"
Tromsø (Norwegian pronunciation: [ˈtrʊmsœ] ( listen); Northern Sami:
"
u
"
Tromsø (Norwegian pronunciation: [ˈtrʊmsœ] ( listen); Northern Sami:
"
"
Romsa; Finnish: Tromssa[2] Kven: Tromssa) is a city and municipality in
"
u
"
Romsa; Finnish: Tromssa[2] Kven: Tromssa) is a city and municipality in
"
"
Troms county, Norway.
"
,
u
"
Troms county, Norway.
"
,
"
Tromsø lies in Northern Norway. The municipality has a population of
"
u
"
Tromsø lies in Northern Norway. The municipality has a population of
"
"
(2015) 72,066, but with an annual influx of students it has over 75,000
"
u
"
(2015) 72,066, but with an annual influx of students it has over 75,000
"
"
most of the year.
"
u
"
most of the year.
"
"
The city centre of Tromsø contains the highest number of old wooden
"
u
"
The city centre of Tromsø contains the highest number of old wooden
"
"
houses in Northern Norway, the oldest house dating from 1789. The Arctic
"
u
"
houses in Northern Norway, the oldest house dating from 1789. The Arctic
"
"
Cathedral, a modern church from 1965, is probably the most famous landmark
"
u
"
Cathedral, a modern church from 1965, is probably the most famous landmark
"
"
in Tromsø.
"
,
u
"
in Tromsø.
"
,
]
]
desc
=
summarize_paragraphs
(
example_paras
,
min_size
=
200
,
max_size
=
500
)
desc
=
summarize_paragraphs
(
example_paras
,
min_size
=
200
,
max_size
=
500
)
self
.
assertEquals
(
self
.
assertEquals
(
desc
,
desc
,
"
Tromsø (Norwegian pronunciation: [ˈtrʊmsœ] ( listen); Northern Sami:
"
u
"
Tromsø (Norwegian pronunciation: [ˈtrʊmsœ] ( listen); Northern Sami:
"
"
Romsa; Finnish: Tromssa[2] Kven: Tromssa) is a city and municipality in
"
u
"
Romsa; Finnish: Tromssa[2] Kven: Tromssa) is a city and municipality in
"
"
Troms county, Norway.
\n
"
u
"
Troms county, Norway.
\n
"
"
\n
"
u
"
\n
"
"
Tromsø lies in Northern Norway. The municipality has a population of
"
u
"
Tromsø lies in Northern Norway. The municipality has a population of
"
"
(2015) 72,066, but with an annual influx of students it has over 75,000
"
u
"
(2015) 72,066, but with an annual influx of students it has over 75,000
"
"
most of the year. The city centre of Tromsø contains the highest number
"
u
"
most of the year. The city centre of Tromsø contains the highest number
"
"
of old wooden houses in Northern Norway, the oldest house dating from
"
u
"
of old wooden houses in Northern Norway, the oldest house dating from
"
"
1789. The Arctic Cathedral, a modern church…
"
u
"
1789. The Arctic Cathedral, a modern church…
"
)
)
class
PreviewUrlTestCase
(
unittest
.
TestCase
):
class
PreviewUrlTestCase
(
unittest
.
TestCase
):
def
test_simple
(
self
):
def
test_simple
(
self
):
html
=
"""
html
=
u
"""
<html>
<html>
<head><title>Foo</title></head>
<head><title>Foo</title></head>
<body>
<body>
...
@@ -155,12 +155,12 @@ class PreviewUrlTestCase(unittest.TestCase):
...
@@ -155,12 +155,12 @@ class PreviewUrlTestCase(unittest.TestCase):
og
=
decode_and_calc_og
(
html
,
"
http://example.com/test.html
"
)
og
=
decode_and_calc_og
(
html
,
"
http://example.com/test.html
"
)
self
.
assertEquals
(
og
,
{
self
.
assertEquals
(
og
,
{
"
og:title
"
:
"
Foo
"
,
u
"
og:title
"
:
u
"
Foo
"
,
"
og:description
"
:
"
Some text.
"
u
"
og:description
"
:
u
"
Some text.
"
})
})
def
test_comment
(
self
):
def
test_comment
(
self
):
html
=
"""
html
=
u
"""
<html>
<html>
<head><title>Foo</title></head>
<head><title>Foo</title></head>
<body>
<body>
...
@@ -173,12 +173,12 @@ class PreviewUrlTestCase(unittest.TestCase):
...
@@ -173,12 +173,12 @@ class PreviewUrlTestCase(unittest.TestCase):
og
=
decode_and_calc_og
(
html
,
"
http://example.com/test.html
"
)
og
=
decode_and_calc_og
(
html
,
"
http://example.com/test.html
"
)
self
.
assertEquals
(
og
,
{
self
.
assertEquals
(
og
,
{
"
og:title
"
:
"
Foo
"
,
u
"
og:title
"
:
u
"
Foo
"
,
"
og:description
"
:
"
Some text.
"
u
"
og:description
"
:
u
"
Some text.
"
})
})
def
test_comment2
(
self
):
def
test_comment2
(
self
):
html
=
"""
html
=
u
"""
<html>
<html>
<head><title>Foo</title></head>
<head><title>Foo</title></head>
<body>
<body>
...
@@ -194,12 +194,12 @@ class PreviewUrlTestCase(unittest.TestCase):
...
@@ -194,12 +194,12 @@ class PreviewUrlTestCase(unittest.TestCase):
og
=
decode_and_calc_og
(
html
,
"
http://example.com/test.html
"
)
og
=
decode_and_calc_og
(
html
,
"
http://example.com/test.html
"
)
self
.
assertEquals
(
og
,
{
self
.
assertEquals
(
og
,
{
"
og:title
"
:
"
Foo
"
,
u
"
og:title
"
:
u
"
Foo
"
,
"
og:description
"
:
"
Some text.
\n\n
Some more text.
\n\n
Text
\n\n
More text
"
u
"
og:description
"
:
u
"
Some text.
\n\n
Some more text.
\n\n
Text
\n\n
More text
"
})
})
def
test_script
(
self
):
def
test_script
(
self
):
html
=
"""
html
=
u
"""
<html>
<html>
<head><title>Foo</title></head>
<head><title>Foo</title></head>
<body>
<body>
...
@@ -212,6 +212,6 @@ class PreviewUrlTestCase(unittest.TestCase):
...
@@ -212,6 +212,6 @@ class PreviewUrlTestCase(unittest.TestCase):
og
=
decode_and_calc_og
(
html
,
"
http://example.com/test.html
"
)
og
=
decode_and_calc_og
(
html
,
"
http://example.com/test.html
"
)
self
.
assertEquals
(
og
,
{
self
.
assertEquals
(
og
,
{
"
og:title
"
:
"
Foo
"
,
u
"
og:title
"
:
u
"
Foo
"
,
"
og:description
"
:
"
Some text.
"
u
"
og:description
"
:
u
"
Some text.
"
})
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment