Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
apt_exercises
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
Andreas Fischer
apt_exercises
Commits
07e1fd77
Commit
07e1fd77
authored
4 years ago
by
Andreas Fischer
Browse files
Options
Downloads
Patches
Plain Diff
Added unit tests
parent
27748767
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test_html_writer.py
+51
-0
51 additions, 0 deletions
test_html_writer.py
with
51 additions
and
0 deletions
test_html_writer.py
0 → 100644
+
51
−
0
View file @
07e1fd77
#!/usr/bin/env python3
import
unittest
from
html_writer
import
read_html
,
read_csv
,
csv_to_html
,
combine_template_with_data
class
TestHTMLWriter
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
csvdata
=
[[
"
First
"
,
"
Last
"
,
"
E-Mail
"
]]
self
.
htmldata
=
"
<tr><td>A</td><td>B</td><td>C</td></tr>
"
self
.
template
=
read_html
()
def
test_read_csv_type
(
self
):
result
=
read_csv
(
"
test.csv
"
)
self
.
assertIsInstance
(
result
,
list
)
def
test_read_csv_data
(
self
):
result
=
read_csv
(
"
test.csv
"
)
first
=
result
[
0
][
0
]
self
.
assertEqual
(
first
,
"
Andreas
"
)
def
test_csv_to_html_type
(
self
):
htmlstring
=
csv_to_html
(
self
.
csvdata
)
self
.
assertIsInstance
(
htmlstring
,
str
)
def
test_csv_to_html_is_table_row
(
self
):
htmlstring
=
csv_to_html
(
self
.
csvdata
)
self
.
assertIn
(
"
<tr>
"
,
htmlstring
)
self
.
assertIn
(
"
</tr>
"
,
htmlstring
)
def
test_csv_to_html_has_table_data
(
self
):
htmlstring
=
csv_to_html
(
self
.
csvdata
)
self
.
assertIn
(
"
<td>
"
,
htmlstring
)
self
.
assertIn
(
"
</td>
"
,
htmlstring
)
def
test_csv_to_html_replaced_brackets
(
self
):
htmlstring
=
csv_to_html
(
self
.
csvdata
)
self
.
assertNotIn
(
"
{}
"
,
htmlstring
)
def
test_combine_template_with_data_type
(
self
):
content
=
combine_template_with_data
(
self
.
template
,
""
)
self
.
assertIsInstance
(
content
,
str
)
def
test_combine_template_with_data_replace
(
self
):
content
=
combine_template_with_data
(
self
.
template
,
self
.
htmldata
)
self
.
assertTrue
(
content
.
startswith
(
"
<!DOCTYPE html>
"
))
self
.
assertTrue
(
content
.
endswith
(
"
</html>
\n
"
))
self
.
assertNotIn
(
"
{}
"
,
content
)
if
__name__
==
"
__main__
"
:
unittest
.
main
()
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