Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
ska-logging
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
LOFAR2.0
ska-logging
Commits
403ed13c
Unverified
Commit
403ed13c
authored
4 years ago
by
SKAJohanVenter
Browse files
Options
Downloads
Patches
Plain Diff
SAR-150
Updated test names. Simplified ThreadingLogsGenerator
parent
569def50
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_transactions.py
+2
-2
2 additions, 2 deletions
tests/test_transactions.py
tests/test_transactions_threaded.py
+14
-26
14 additions, 26 deletions
tests/test_transactions_threaded.py
with
16 additions
and
28 deletions
tests/test_transactions.py
+
2
−
2
View file @
403ed13c
...
@@ -191,7 +191,7 @@ class TestTransactionLogging:
...
@@ -191,7 +191,7 @@ class TestTransactionLogging:
assert
last_log_message
.
funcName
==
"
test_log_override_enter_exit_no_logger
"
assert
last_log_message
.
funcName
==
"
test_log_override_enter_exit_no_logger
"
assert
last_log_message
.
filename
==
"
test_transactions.py
"
assert
last_log_message
.
filename
==
"
test_transactions.py
"
def
test_specified_logger
(
self
):
def
test_specified_logger
_is_used
(
self
):
logger
=
MagicMock
()
logger
=
MagicMock
()
parameters
=
{}
parameters
=
{}
with
transaction
(
"
name
"
,
parameters
,
logger
=
logger
)
as
transaction_id
:
with
transaction
(
"
name
"
,
parameters
,
logger
=
logger
)
as
transaction_id
:
...
@@ -200,7 +200,7 @@ class TestTransactionLogging:
...
@@ -200,7 +200,7 @@ class TestTransactionLogging:
assert
logger
.
info
.
call_args_list
[
i
].
starts_with
(
message
)
assert
logger
.
info
.
call_args_list
[
i
].
starts_with
(
message
)
assert
logger
.
info
.
call_count
==
4
,
f
"
Log calls incorrect
{
logger
.
info
.
call_args_list
}
"
assert
logger
.
info
.
call_count
==
4
,
f
"
Log calls incorrect
{
logger
.
info
.
call_args_list
}
"
def
test_unspecified_logger
(
self
):
def
test_unspecified_logger
_is_not_used
(
self
):
logger
=
MagicMock
()
logger
=
MagicMock
()
parameters
=
{}
parameters
=
{}
with
transaction
(
"
name
"
,
parameters
)
as
transaction_id
:
with
transaction
(
"
name
"
,
parameters
)
as
transaction_id
:
...
...
This diff is collapsed.
Click to expand it.
tests/test_transactions_threaded.py
+
14
−
26
View file @
403ed13c
...
@@ -18,18 +18,9 @@ class ThreadingLogsGenerator:
...
@@ -18,18 +18,9 @@ class ThreadingLogsGenerator:
self
.
pass_logger
=
pass_logger
self
.
pass_logger
=
pass_logger
def
thread_with_transaction_exception
(
self
,
thread_index
):
def
thread_with_transaction_exception
(
self
,
thread_index
):
if
self
.
pass_logger
:
logger
=
self
.
logger
if
self
.
pass_logger
else
None
try
:
try
:
with
transaction
(
f
"
Transaction thread [
{
thread_index
}
]
"
,
logger
=
self
.
logger
):
with
transaction
(
f
"
Transaction thread [
{
thread_index
}
]
"
,
logger
=
logger
):
self
.
logger
.
info
(
f
"
Transaction thread in transaction [
{
thread_index
}
], in transaction
"
)
raise
RuntimeError
(
"
An exception has occurred
"
)
except
RuntimeError
:
pass
else
:
try
:
with
transaction
(
f
"
Transaction thread [
{
thread_index
}
]
"
):
self
.
logger
.
info
(
self
.
logger
.
info
(
f
"
Transaction thread in transaction [
{
thread_index
}
], in transaction
"
f
"
Transaction thread in transaction [
{
thread_index
}
], in transaction
"
)
)
...
@@ -38,15 +29,12 @@ class ThreadingLogsGenerator:
...
@@ -38,15 +29,12 @@ class ThreadingLogsGenerator:
pass
pass
def
thread_with_transaction
(
self
,
thread_index
):
def
thread_with_transaction
(
self
,
thread_index
):
if
self
.
pass_logger
:
logger
=
self
.
logger
if
self
.
pass_logger
else
None
with
transaction
(
f
"
Transaction thread [
{
thread_index
}
]
"
,
logger
=
self
.
logger
):
with
transaction
(
f
"
Transaction thread [
{
thread_index
}
]
"
,
logger
=
logger
):
self
.
logger
.
info
(
f
"
Transaction thread [
{
thread_index
}
], in transaction
"
)
self
.
logger
.
info
(
f
"
Thread log [
{
thread_index
}
], no transaction
"
)
else
:
with
transaction
(
f
"
Transaction thread [
{
thread_index
}
]
"
):
self
.
logger
.
info
(
f
"
Transaction thread [
{
thread_index
}
], in transaction
"
)
self
.
logger
.
info
(
f
"
Transaction thread [
{
thread_index
}
], in transaction
"
)
self
.
logger
.
info
(
f
"
Thread log [
{
thread_index
}
], no transaction
"
)
self
.
logger
.
info
(
f
"
Thread log [
{
thread_index
}
], no transaction
"
)
def
thread_without_transaction
(
self
,
thread_index
):
def
thread_without_transaction
(
self
,
thread_index
):
self
.
logger
.
info
(
f
"
Thread log [
{
thread_index
}
], no transaction
"
)
self
.
logger
.
info
(
f
"
Thread log [
{
thread_index
}
], no transaction
"
)
...
...
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