Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fact_pdf_report
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
fact-depend
fact_pdf_report
Commits
e1afb38c
Commit
e1afb38c
authored
Jul 08, 2020
by
lwilms
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete old and add one new test
parent
fe98b5dd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
29 deletions
+12
-29
test_template_engine.py
test/unit/tex_generation/test_template_engine.py
+12
-29
No files found.
test/unit/tex_generation/test_template_engine.py
View file @
e1afb38c
...
...
@@ -2,10 +2,13 @@ from pathlib import Path
import
pytest
from
pdf_generator.tex_generation.template_engine
import
(
TemplateEngine
,
decode_base64_to_file
,
render_number_as_size
,
render_
number_as_string
,
render_
unix_time
,
replace_
characters_in_list
,
replace_special_characters
,
split_hash_string
,
split_long_lin
es
TemplateEngine
,
decode_base64_to_file
,
render_number_as_size
,
render_unix_time
,
replace_
special_characters
,
get_five_longest_entri
es
)
from
test.data.test_dict
import
TEST_DICT
# pylint: disable=redefined-outer-name
...
...
@@ -22,17 +25,6 @@ def test_byte_number_filter():
assert
render_number_as_size
(
128000
,
verbose
=
False
)
==
'125.00 KiB'
def
test_nice_number_filter
():
assert
render_number_as_string
(
None
)
==
'not available'
assert
render_number_as_string
(
'no int'
)
==
'not available'
assert
render_number_as_string
(
12
)
==
'12'
assert
render_number_as_string
(
12.1
)
==
'12.10'
assert
render_number_as_string
(
12.101
)
==
'12.10'
assert
render_number_as_string
(
12.109
)
==
'12.11'
assert
render_number_as_string
(
'12'
)
==
'12'
@pytest.mark.skip
(
reason
=
'Since local time used, result is not stable'
)
def
test_nice_unix_time
():
assert
render_unix_time
(
None
)
==
'not available'
...
...
@@ -40,16 +32,6 @@ def test_nice_unix_time():
assert
render_unix_time
(
10
)
==
'1970-01-01 01:00:10'
def
test_split_hash
():
assert
split_hash_string
(
'X'
*
62
)
==
'{}
\n
X'
.
format
(
'X'
*
61
)
assert
split_hash_string
(
'X'
*
61
)
==
'X'
*
61
def
test_split_output_lines
():
assert
split_long_lines
(
'X
\n
X'
)
==
'X
\n
X'
assert
split_long_lines
(
'{}
\n
X'
.
format
(
'X'
*
93
))
==
'{}
\n
X
\n
X'
.
format
(
'X'
*
92
)
def
test_convert_base64_to_png_filter
(
tmpdir
):
decode_base64_to_file
(
'0000'
,
'testfile'
,
str
(
tmpdir
))
assert
Path
(
str
(
tmpdir
),
'testfile.png'
)
.
read_bytes
()
==
b
'
\xd3\x4d\x34
'
...
...
@@ -62,12 +44,6 @@ def test_filter_latex_special_chars():
assert
replace_special_characters
(
r'100 $'
)
==
r'100 \$'
def
test_filter_chars_in_list
():
assert
replace_characters_in_list
([])
==
[]
assert
replace_characters_in_list
([
r'safe'
,
r'un\safe'
])
==
[
'safe'
,
'unsafe'
]
def
test_render_meta_template
(
stub_engine
):
assert
stub_engine
.
render_meta_template
(
meta_data
=
'anything'
)
==
'Test anything - '
...
...
@@ -78,3 +54,10 @@ def test_render_main_template(stub_engine):
def
test_render_analysis_template
(
stub_engine
):
assert
stub_engine
.
render_analysis_template
(
plugin
=
'non_existing'
,
analysis
=
'result'
)
==
'Presenting: result'
def
test_get_five_longest_entries
():
assert
len
(
get_five_longest_entries
(
TEST_DICT
[
'firmware'
][
'analysis'
][
'file_type'
][
'summary'
],
top
=
3
))
<=
3
longest_dict
=
get_five_longest_entries
(
TEST_DICT
[
'firmware'
][
'analysis'
][
'file_type'
][
'summary'
],
top
=
1
)
assert
len
(
longest_dict
)
==
1
assert
'text/plain'
in
longest_dict
.
keys
()
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