https://bugzilla.redhat.com/show_bug.cgi?id=2220180
--- Comment #1 from Joel Capitao <jcapitao(a)redhat.com> ---
=================================== FAILURES
===================================
____________________ TestDaiquiri.test_setup_json_formatter
____________________
self = <daiquiri.tests.test_daiquiri.TestDaiquiri
testMethod=test_setup_json_formatter>
def test_setup_json_formatter(self) -> None:
stream = io.StringIO()
daiquiri.setup(
outputs=(
daiquiri.output.Stream(
stream, formatter=daiquiri.formatter.JSON_FORMATTER
),
)
)
daiquiri.getLogger(__name__).warning("foobar")
self.assertEqual({"message": "foobar"},
json.loads(stream.getvalue()))
E AssertionError: {'message':
'foobar'} != {'message': 'foobar',
'taskName': None}
E - {'message': 'foobar'}
E + {'message': 'foobar', 'taskName': None}
daiquiri/tests/test_daiquiri.py:42: AssertionError
______________ TestDaiquiri.test_setup_json_formatter_with_extras
______________
self = <daiquiri.tests.test_daiquiri.TestDaiquiri
testMethod=test_setup_json_formatter_with_extras>
def test_setup_json_formatter_with_extras(self) -> None:
stream = io.StringIO()
daiquiri.setup(
outputs=(
daiquiri.output.Stream(
stream, formatter=daiquiri.formatter.JSON_FORMATTER
),
)
)
daiquiri.getLogger(__name__).warning("foobar", foo="bar")
self.assertEqual(
{"message":
"foobar", "foo": "bar"}, json.loads(stream.getvalue())
)
E AssertionError: {'message': 'foobar', 'foo':
'bar'} != {'message':
'foobar', 'taskName': None, 'foo': 'bar'}
E - {'foo': 'bar', 'message': 'foobar'}
E + {'foo': 'bar', 'message': 'foobar',
'taskName': None}
E ? ++++++++++++++++++
daiquiri/tests/test_daiquiri.py:54: AssertionError
___________________________ TestOutput.test_datadog
____________________________
self = <daiquiri.tests.test_output.TestOutput testMethod=test_datadog>
def test_datadog(self) -> None:
with mock.patch("socket.socket") as mock_socket:
socket_instance = mock_socket.return_value
daiquiri.setup(outputs=(daiquiri.output.Datadog(),),
level=logging.DEBUG)
logger = daiquiri.getLogger()
logger.error("foo", bar=1)
logger.info("bar")
try:
1 / 0
except ZeroDivisionError:
logger = daiquiri.getLogger("saymyname")
logger.error("backtrace", exc_info=True)
socket_instance.connect.assert_called_once_with(("127.0.0.1",
10518))
socket_instance.sendall.assert_has_calls(
[
mock.call(
DatadogMatcher(
{
"status": "error",
"message": "foo",
"bar": 1,
"logger": {"name": "root"},
"timestamp": mock.ANY,
}
)
),
mock.call(
DatadogMatcher(
{
"status": "info",
"message": "bar",
"logger": {"name": "root"},
"timestamp": mock.ANY,
}
)
),
mock.call(
DatadogMatcher(
{
"status": "error",
"message": "backtrace",
"logger": {"name":
"saymyname"},
"timestamp": mock.ANY,
"error": {
"kind": "ZeroDivisionError",
"stack": None,
"message": mock.ANY,
},
}
)
),
]
)
daiquiri/tests/test_output.py:109:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MagicMock name='socket().sendall' id='140706521580896'>
calls = [call(b'{"status": "error", "message":
"foo", "bar": 1, "logger":
{"name": "root"}, "timestamp":
"unserializable"}\n')..."timestamp":
"unserializable", "error": {"kind":
"ZeroDivisionError", "stack": null,
"message": "unserializable"}}\n')]
any_order = False
def assert_has_calls(self, calls, any_order=False):
"""assert the mock has been called with the specified calls.
The `mock_calls` list is checked for the calls.
If `any_order` is False (the default) then the calls must be
sequential. There can be extra calls before or after the
specified calls.
If `any_order` is True then the calls can be in any order, but
they must all appear in `mock_calls`."""
expected = [self._call_matcher(c) for c in calls]
cause = next((e for e in expected if isinstance(e, Exception)), None)
all_calls = _CallList(self._call_matcher(c) for c in self.mock_calls)
if not any_order:
if expected not in all_calls:
if cause is None:
problem = 'Calls not found.'
else:
problem = ('Error processing expected calls.\n'
'Errors: {}').format(
[e if isinstance(e, Exception) else None
for e in expected])
raise AssertionError(
f'{problem}\n'
f'Expected: {_CallList(calls)}'
f'{self._calls_repr(prefix="Actual").rstrip(".")}'
) from cause
E AssertionError: Calls not found.
E Expected: [call(b'{"status": "error",
"message": "foo", "bar":
1, "logger": {"name": "root"}, "timestamp":
"unserializable"}\n'),
E call(b'{"status": "info", "message":
"bar", "logger": {"name":
"root"}, "timestamp": "unserializable"}\n'),
E call(b'{"status": "error", "message":
"backtrace", "logger":
{"name": "saymyname"}, "timestamp":
"unserializable", "error": {"kind":
"ZeroDivisionError", "stack": null, "message":
"unserializable"}}\n')]
E Actual: [call(b'{"message": "foo",
"taskName": null, "bar": 1,
"timestamp": "2023-07-10T14:54:54.024694+00:00", "status":
"error", "logger":
{"name": "root"}}\n'),
E call(b'{"message": "bar", "taskName":
null, "timestamp":
"2023-07-10T14:54:54.027714+00:00", "status": "info",
"logger": {"name":
"root"}}\n'),
E call(b'{"message": "backtrace",
"taskName": null, "timestamp":
"2023-07-10T14:54:54.027859+00:00", "status": "error",
"logger": {"name":
"saymyname"}, "error": {"kind":
"ZeroDivisionError", "stack": null, "message":
"Traceback (most recent call last):\\n File
\\"/builddir/build/BUILD/daiquiri-3.2.1/daiquiri/tests/test_output.py\\", line
104, in test_datadog\\n 1 / 0\\n ~~^~~\\nZeroDivisionError: division by
zero"}}\n')]
/usr/lib64/python3.12/unittest/mock.py:981: AssertionError
=========================== short test summary info
============================
FAILED daiquiri/tests/test_daiquiri.py::TestDaiquiri::test_setup_json_formatter
FAILED
daiquiri/tests/test_daiquiri.py::TestDaiquiri::test_setup_json_formatter_with_extras
FAILED daiquiri/tests/test_output.py::TestOutput::test_datadog -
AssertionErr...
=================== 3 failed, 17 passed, 1 warning in 0.21s
====================
--
You are receiving this mail because:
You are on the CC list for the bug.
https://bugzilla.redhat.com/show_bug.cgi?id=2220180
Report this comment as SPAM:
https://bugzilla.redhat.com/enter_bug.cgi?product=Bugzilla&format=rep...