Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Kulya
OpnSense
Commits
cc2b7044
Commit
cc2b7044
authored
Feb 10, 2016
by
Ad Schellevis
Committed by
Franco Fichtner
Feb 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(configd) add unit test
(cherry picked from commit
4ece564c
)
parent
5327d19d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
template.py
src/opnsense/service/tests/template.py
+28
-0
No files found.
src/opnsense/service/tests/template.py
View file @
cc2b7044
...
...
@@ -33,6 +33,7 @@ import collections
from
modules
import
config
from
modules
import
template
class
TestConfigMethods
(
unittest
.
TestCase
):
def
setUp
(
self
):
""" setup test, load config
...
...
@@ -94,3 +95,30 @@ class TestTemplateMethods(unittest.TestCase):
"""
generated_filenames
=
self
.
tmpl
.
generate
(
'OPNsense.Sample'
)
self
.
assertEquals
(
len
(
generated_filenames
),
3
,
'number of output files <> 3'
)
def
test_all
(
self
):
""" Test if all expected templates are created, can only find test for static defined cases.
Calls "generate *" and compares that to all defined templates in all +TARGET files
Fails on first missing case.
:return:
"""
self
.
expected_filenames
=
dict
()
self
.
generated_filenames
=
list
()
templates_path
=
'
%
s/../templates'
%
'/'
.
join
(
__file__
.
split
(
'/'
)[:
-
1
])
for
root
,
dirs
,
files
in
os
.
walk
(
templates_path
):
for
filenm
in
files
:
if
filenm
==
'+TARGETS'
:
filename
=
'
%
s/
%
s'
%
(
root
,
filenm
)
for
line
in
open
(
filename
)
.
read
()
.
split
(
'
\n
'
):
line
=
line
.
strip
()
if
len
(
line
)
>
1
and
line
[
0
]
!=
'#'
and
line
.
find
(
'['
)
==
-
1
:
expected_filename
=
(
'
%
s
%
s'
%
(
self
.
output_path
,
line
.
split
(
':'
)[
-
1
]))
.
replace
(
'//'
,
'/'
)
self
.
expected_filenames
[
expected_filename
]
=
{
'src'
:
filename
}
for
filename
in
self
.
tmpl
.
generate
(
'*'
):
if
filename
.
find
(
'capt'
)
==
-
1
:
self
.
generated_filenames
.
append
(
filename
.
replace
(
'//'
,
'/'
))
for
expected_filename
in
self
.
expected_filenames
:
message
=
'missing
%
s (
%
s'
%
(
expected_filename
,
self
.
expected_filenames
[
expected_filename
][
'src'
])
self
.
assertIn
(
expected_filename
,
self
.
generated_filenames
,
message
)
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