Skip to content
GitLab
Explore
Sign in
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
GitLab 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
199509b6
Unverified
Commit
199509b6
authored
4 years ago
by
Katleho Madisa
Browse files
Options
Downloads
Patches
Plain Diff
SAR-149
Added a test for the parameter validation step.
parent
c544e2ff
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_transactions.py
+12
-18
12 additions, 18 deletions
tests/test_transactions.py
with
12 additions
and
18 deletions
tests/test_transactions.py
+
12
−
18
View file @
199509b6
...
...
@@ -10,7 +10,7 @@ import concurrent.futures
from
unittest.mock
import
patch
,
MagicMock
from
ska.logging
import
transaction
from
ska.logging.transactions
import
TransactionIdGenerator
from
ska.logging.transactions
import
TransactionIdGenerator
,
TransactionParamsError
from
tests.conftest
import
(
get_first_record_and_log_message
,
get_last_record_and_log_message
,
...
...
@@ -22,15 +22,19 @@ from tests.conftest import (
class
TestTransactionIdGeneration
:
"""
Tests for :class:`~ska.logging.transaction` related to ID generation.
"""
def
test_error_if_params_type_is_not_mapping
(
self
):
parameters
=
[]
with
pytest
.
raises
(
TransactionParamsError
):
with
transaction
(
"
name
"
,
parameters
):
pass
def
test_preference_order
(
self
,
id_generator_stub
):
parameters
=
{
"
other
"
:
"
config
"
,
"
transaction_id
"
:
"
xyz123
"
,
"
other_transaction_id_key
"
:
"
def789
"
,
}
with
transaction
(
"
name
"
,
parameters
,
transaction_id
=
"
abc1234
"
)
as
transaction_id
:
with
transaction
(
"
name
"
,
parameters
,
transaction_id
=
"
abc1234
"
)
as
transaction_id
:
assert
transaction_id
==
"
abc1234
"
parameters
=
{
...
...
@@ -100,9 +104,7 @@ class TestTransactionIdGeneration:
class
TestTransactionLogging
:
"""
Tests for :class:`~ska.logging.transaction` related to logging.
"""
def
test_name_and_id_and_params_in_context_handler
(
self
,
id_generator_stub
,
recording_logger
):
def
test_name_and_id_and_params_in_context_handler
(
self
,
id_generator_stub
,
recording_logger
):
parameters
=
{
"
other
"
:
[
"
config
"
,
1
,
2
,
3.0
]}
with
transaction
(
"
name
"
,
parameters
)
as
transaction_id
:
pass
...
...
@@ -123,9 +125,7 @@ class TestTransactionLogging:
assert
"
name
"
in
last_log_message
assert
transaction_id
in
last_log_message
def
test_exception_logs_transaction_id_and_command
(
self
,
id_generator_stub
,
recording_logger
):
def
test_exception_logs_transaction_id_and_command
(
self
,
id_generator_stub
,
recording_logger
):
parameters
=
{
"
other
"
:
[
"
config
"
,
1
,
2
,
3.0
]}
with
pytest
.
raises
(
RuntimeError
):
with
transaction
(
"
name
"
,
parameters
)
as
transaction_id
:
...
...
@@ -133,16 +133,10 @@ class TestTransactionLogging:
record_logs
=
get_all_record_logs
(
recording_logger
)
for
log_msg
in
record_logs
:
if
(
"
RuntimeError
"
in
log_msg
and
transaction_id
in
log_msg
and
"
name
"
in
log_msg
):
if
"
RuntimeError
"
in
log_msg
and
transaction_id
in
log_msg
and
"
name
"
in
log_msg
:
return
assert
(
0
),
f
"
RuntimeError and transaction tag not found in exception logs:
{
record_logs
}
"
assert
0
,
f
"
RuntimeError and transaction tag not found in exception logs:
{
record_logs
}
"
class
TestTransactionIdGenerator
:
...
...
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