Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
apertis-test-cases
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Walter Lozano
apertis-test-cases
Commits
ab5b4c0f
Commit
ab5b4c0f
authored
6 years ago
by
Luis Araujo
Browse files
Options
Downloads
Patches
Plain Diff
Rename some functions with more accurate names
Signed-off-by:
Luis Araujo
<
luis.araujo@collabora.co.uk
>
parent
2d81d93d
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
renderer/make_page.py
+9
-14
9 additions, 14 deletions
renderer/make_page.py
with
9 additions
and
14 deletions
renderer/make_page.py
+
9
−
14
View file @
ab5b4c0f
...
...
@@ -9,8 +9,8 @@ from jinja2 import Environment, FileSystemLoader
TEMPLATE_DIR
=
"
.
"
# This command make
s
sure the following formatting
applies for the respective
# sections:
# This command
parse lists to
make sure the following formatting
#
applies for the respective
sections:
#
# pre-conditions:
# - Start line with '#' or '$' for commands, everything else is a comment.
...
...
@@ -21,14 +21,12 @@ TEMPLATE_DIR="."
# run: steps:
# - Star '#' for comments , everything else is a command.
#
def
comments_commands
(
lines
,
run
=
False
):
def
parse_list
(
lines
,
run
=
False
):
processed_lines
=
[]
for
line
in
lines
:
p
,
c
=
''
,
''
sline
=
line
.
strip
()
if
not
sline
:
processed_lines
.
append
((
p
,
c
))
continue
if
run
:
...
...
@@ -48,7 +46,7 @@ def comments_commands(lines, run=False):
return
processed_lines
def
parse_format
(
testcase_data
):
def
get_template_values
(
testcase_data
):
template_values
=
{}
# Mandatory fields
...
...
@@ -62,7 +60,7 @@ def parse_format(testcase_data):
value
=
metadata
.
get
(
mv
)
if
value
:
if
mv
==
'
expected
'
:
template_values
.
update
({
mv
:
comments_commands
(
value
)
})
template_values
.
update
({
mv
:
parse_list
(
value
)
})
else
:
template_values
.
update
({
mv
.
replace
(
'
-
'
,
'
_
'
)
:
value
})
else
:
...
...
@@ -78,15 +76,13 @@ def parse_format(testcase_data):
if
not
steps
:
print
(
"
Error: missing mandatory field steps for run
"
)
sys
.
exit
(
1
)
template_values
.
update
({
'
run_steps
'
:
comments_commands
(
steps
,
run
=
True
)
})
template_values
.
update
({
'
run_steps
'
:
parse_list
(
steps
,
run
=
True
)
})
# No mandatory fields
for
nm
in
[
'
notes
'
,
'
format
'
,
'
maintainer
'
,
'
resources
'
,
'
pre-conditions
'
]:
value
=
metadata
.
get
(
nm
)
if
value
:
template_values
.
update
({
nm
.
replace
(
'
-
'
,
'
_
'
)
:
comments_commands
(
value
)
template_values
.
update
({
nm
.
replace
(
'
-
'
,
'
_
'
)
:
parse_list
(
value
)
if
nm
in
[
'
notes
'
,
'
pre-conditions
'
]
else
value
})
...
...
@@ -102,18 +98,17 @@ def parse_format(testcase_data):
if
'
__main__
'
==
__name__
:
testcase_file
=
sys
.
argv
[
1
]
try
:
with
open
(
testcase_file
)
as
testcase
:
t
estcase
_data
=
yaml
.
safe_load
(
testcase
)
t
c
_data
=
yaml
.
safe_load
(
testcase
)
except
yaml
.
scanner
.
ScannerError
as
e
:
print
(
"
yaml format error:
"
,
e
)
sys
.
exit
(
1
)
env
=
Environment
(
loader
=
FileSystemLoader
([
TEMPLATE_DIR
]))
# Get template from environment and render it.
data
=
env
.
get_template
(
'
index.html
'
).
render
(
parse_format
(
t
estc
ase
_data
))
data
=
env
.
get_template
(
'
index.html
'
).
render
(
get_template_valu
es
(
tc_data
))
print
(
data
)
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