Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lu Xu
slapos
Commits
cc056efe
Commit
cc056efe
authored
Apr 20, 2020
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/plantuml/test: Use ImageComparisonTestCase
This code have been moved to slapos.core
parent
58a3efb3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
19 deletions
+2
-19
software/plantuml/test/test.py
software/plantuml/test/test.py
+2
-19
No files found.
software/plantuml/test/test.py
View file @
cc056efe
...
...
@@ -37,6 +37,7 @@ import plantuml
from
slapos.recipe.librecipe
import
generateHashFromFiles
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
from
slapos.testing.utils
import
ImageComparisonTestCase
setUpModule
,
PlantUMLTestCase
=
makeModuleSetUpAndTestCaseClass
(
...
...
@@ -44,7 +45,7 @@ setUpModule, PlantUMLTestCase = makeModuleSetUpAndTestCaseClass(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'software.cfg'
)))
class
TestSimpleDiagram
(
PlantUMLTestCase
):
class
TestSimpleDiagram
(
PlantUMLTestCase
,
ImageComparisonTestCase
):
def
setUp
(
self
):
self
.
url
=
self
.
computer_partition
.
getConnectionParameterDict
()[
"url"
]
self
.
plantuml
=
plantuml
.
PlantUML
(
...
...
@@ -52,24 +53,6 @@ class TestSimpleDiagram(PlantUMLTestCase):
http_opts
=
{
"disable_ssl_certificate_validation"
:
True
}
)
def
assertImagesSimilar
(
self
,
i1
,
i2
,
tolerance
=
5
):
"""Assert images difference between images is less than `tolerance` %.
taken from https://rosettacode.org/wiki/Percentage_difference_between_images
"""
pairs
=
zip
(
i1
.
getdata
(),
i2
.
getdata
())
if
len
(
i1
.
getbands
())
==
1
:
# for gray-scale jpegs
dif
=
sum
(
abs
(
p1
-
p2
)
for
p1
,
p2
in
pairs
)
else
:
dif
=
sum
(
abs
(
c1
-
c2
)
for
p1
,
p2
in
pairs
for
c1
,
c2
in
zip
(
p1
,
p2
))
ncomponents
=
i1
.
size
[
0
]
*
i1
.
size
[
1
]
*
3
self
.
assertLessEqual
((
dif
/
255.0
*
100
)
/
ncomponents
,
tolerance
)
def
assertImagesSame
(
self
,
i1
,
i2
):
"""Assert images are exactly same."""
self
.
assertImagesSimilar
(
i1
,
i2
,
0
)
def
test_sequence_diagram
(
self
):
png
=
self
.
plantuml
.
processes
(
textwrap
.
dedent
(
"""
\
@startuml
...
...
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