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
Labels
Merge Requests
105
Merge Requests
105
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
c9e44430
Commit
c9e44430
authored
Jun 30, 2022
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
caddy-frontend/test: Improve assertTestData API
parent
0964a2cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
19 deletions
+16
-19
software/caddy-frontend/test/test.py
software/caddy-frontend/test/test.py
+16
-19
No files found.
software/caddy-frontend/test/test.py
View file @
c9e44430
...
@@ -293,9 +293,9 @@ class TestDataMixin(object):
...
@@ -293,9 +293,9 @@ class TestDataMixin(object):
in
self
.
callSupervisorMethod
(
'getAllProcessInfo'
)
in
self
.
callSupervisorMethod
(
'getAllProcessInfo'
)
if
q
[
'name'
]
!=
'watchdog'
and
q
[
'group'
]
!=
'watchdog'
]))
if
q
[
'name'
]
!=
'watchdog'
and
q
[
'group'
]
!=
'watchdog'
]))
def
assertTestData
(
self
,
runtime_data
,
hash_value
_dict
=
None
,
msg
=
None
):
def
assertTestData
(
self
,
runtime_data
,
data_replacement
_dict
=
None
,
msg
=
None
):
if
hash_value
_dict
is
None
:
if
data_replacement
_dict
is
None
:
hash_value
_dict
=
{}
data_replacement
_dict
=
{}
filename
=
'%s-%s.txt'
%
(
self
.
id
().
replace
(
'zz_'
,
''
),
'CADDY'
)
filename
=
'%s-%s.txt'
%
(
self
.
id
().
replace
(
'zz_'
,
''
),
'CADDY'
)
test_data_file
=
os
.
path
.
join
(
test_data_file
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
'test_data'
,
filename
)
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
'test_data'
,
filename
)
...
@@ -305,9 +305,8 @@ class TestDataMixin(object):
...
@@ -305,9 +305,8 @@ class TestDataMixin(object):
except
IOError
:
except
IOError
:
test_data
=
''
test_data
=
''
for
hash_type
,
hash_value
in
list
(
hash_value_dict
.
items
()):
for
replacement
,
value
in
list
(
data_replacement_dict
.
items
()):
runtime_data
=
runtime_data
.
replace
(
hash_value
,
'{hash-%s}'
%
(
runtime_data
=
runtime_data
.
replace
(
value
,
replacement
)
hash_type
),)
maxDiff
=
self
.
maxDiff
maxDiff
=
self
.
maxDiff
self
.
maxDiff
=
None
self
.
maxDiff
=
None
...
@@ -384,36 +383,34 @@ class TestDataMixin(object):
...
@@ -384,36 +383,34 @@ class TestDataMixin(object):
hash_file_list
=
[
os
.
path
.
join
(
hash_file_list
=
[
os
.
path
.
join
(
self
.
computer_partition_root_path
,
'software_release/buildout.cfg'
)]
self
.
computer_partition_root_path
,
'software_release/buildout.cfg'
)]
hash_value
_dict
=
{
data_replacement
_dict
=
{
'
generic'
:
generateHashFromFiles
(
hash_file_list
),
'
{hash-generic}'
:
generateHashFromFiles
(
hash_file_list
)
}
}
for
caddy_wrapper_path
in
glob
.
glob
(
os
.
path
.
join
(
for
caddy_wrapper_path
in
glob
.
glob
(
os
.
path
.
join
(
self
.
instance_path
,
'*'
,
'bin'
,
'caddy-wrapper'
)):
self
.
instance_path
,
'*'
,
'bin'
,
'caddy-wrapper'
)):
partition_id
=
caddy_wrapper_path
.
split
(
'/'
)[
-
3
]
partition_id
=
caddy_wrapper_path
.
split
(
'/'
)[
-
3
]
hash_value_dict
[
data_replacement_dict
[
'{hash-caddy-%s}'
%
(
partition_id
)]
=
\
'caddy-%s'
%
(
partition_id
)]
=
generateHashFromFiles
(
generateHashFromFiles
([
caddy_wrapper_path
]
+
hash_file_list
)
[
caddy_wrapper_path
]
+
hash_file_list
)
for
backend_haproxy_wrapper_path
in
glob
.
glob
(
os
.
path
.
join
(
for
backend_haproxy_wrapper_path
in
glob
.
glob
(
os
.
path
.
join
(
self
.
instance_path
,
'*'
,
'bin'
,
'backend-haproxy-wrapper'
)):
self
.
instance_path
,
'*'
,
'bin'
,
'backend-haproxy-wrapper'
)):
partition_id
=
backend_haproxy_wrapper_path
.
split
(
'/'
)[
-
3
]
partition_id
=
backend_haproxy_wrapper_path
.
split
(
'/'
)[
-
3
]
hash_value_dict
[
data_replacement_dict
[
'{hash-backend-haproxy-%s}'
%
(
partition_id
)]
=
\
'backend-haproxy-%s'
%
(
partition_id
)]
=
generateHashFromFiles
(
generateHashFromFiles
([
[
backend_haproxy_wrapper_path
]
+
hash_file_list
backend_haproxy_wrapper_path
]
+
hash_file_list
)
)
for
rejected_slave_publish_path
in
glob
.
glob
(
os
.
path
.
join
(
for
rejected_slave_publish_path
in
glob
.
glob
(
os
.
path
.
join
(
self
.
instance_path
,
'*'
,
'etc'
,
'nginx-rejected-slave.conf'
)):
self
.
instance_path
,
'*'
,
'etc'
,
'nginx-rejected-slave.conf'
)):
partition_id
=
rejected_slave_publish_path
.
split
(
'/'
)[
-
3
]
partition_id
=
rejected_slave_publish_path
.
split
(
'/'
)[
-
3
]
rejected_slave_pem_path
=
os
.
path
.
join
(
rejected_slave_pem_path
=
os
.
path
.
join
(
self
.
instance_path
,
partition_id
,
'etc'
,
'rejected-slave.pem'
)
self
.
instance_path
,
partition_id
,
'etc'
,
'rejected-slave.pem'
)
hash_value
_dict
[
data_replacement
_dict
[
'
rejected-slave-publish
'
'
{hash-rejected-slave-publish}
'
]
=
generateHashFromFiles
(
]
=
generateHashFromFiles
(
[
rejected_slave_publish_path
,
rejected_slave_pem_path
]
+
hash_file_list
[
rejected_slave_publish_path
,
rejected_slave_pem_path
]
+
hash_file_list
)
)
runtime_data
=
self
.
getTrimmedProcessInfo
()
runtime_data
=
self
.
getTrimmedProcessInfo
()
self
.
assertTestData
(
runtime_data
,
hash_value_dict
=
hash_value_dict
)
self
.
assertTestData
(
runtime_data
,
data_replacement_dict
=
data_replacement_dict
)
def
fakeHTTPSResult
(
domain
,
path
,
port
=
HTTPS_PORT
,
def
fakeHTTPSResult
(
domain
,
path
,
port
=
HTTPS_PORT
,
...
...
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