cloud-init/cloud-init-20.4-sandbox-ca_certs-tests-to-avoid-failure.patch
DistroBaker 0aef73fe88 Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/cloud-init.git#3f1f240525bc05fe7ceebd1911c157c7a5be0cc6
2021-01-06 11:52:03 +00:00

47 lines
1.8 KiB
Diff

From f16b18607444cb41e263edfa7fb0c97ba1f7e518 Mon Sep 17 00:00:00 2001
From: Eduardo Otubo <otubo@redhat.com>
Date: Fri, 4 Dec 2020 11:05:08 +0100
Subject: [PATCH] Sandbox ca_certs tests to avoid failure
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
---
.../unittests/test_handler/test_handler_ca_certs.py | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/tests/unittests/test_handler/test_handler_ca_certs.py b/tests/unittests/test_handler/test_handler_ca_certs.py
index e74a0a08..a16430d5 100644
--- a/tests/unittests/test_handler/test_handler_ca_certs.py
+++ b/tests/unittests/test_handler/test_handler_ca_certs.py
@@ -152,6 +152,7 @@ class TestAddCaCerts(TestCase):
self.paths = helpers.Paths({
'cloud_dir': tmpdir,
})
+ self.add_patch("cloudinit.config.cc_ca_certs.os.stat", "m_stat")
def test_no_certs_in_list(self):
"""Test that no certificate are written if not provided."""
@@ -215,17 +216,12 @@ class TestAddCaCerts(TestCase):
expected = "cloud-init-ca-certs.crt\n"
- with ExitStack() as mocks:
- mock_write = mocks.enter_context(
- mock.patch.object(util, 'write_file', autospec=True))
- mock_stat = mocks.enter_context(
- mock.patch("cloudinit.config.cc_ca_certs.os.stat")
- )
- mock_stat.return_value.st_size = 0
+ with mock.patch.object(util, 'write_file', autospec=True) as m_write:
+ self.m_stat.return_value.st_size = 0
cc_ca_certs.add_ca_certs([cert])
- mock_write.assert_has_calls([
+ m_write.assert_has_calls([
mock.call("/usr/share/ca-certificates/cloud-init-ca-certs.crt",
cert, mode=0o644),
mock.call("/etc/ca-certificates.conf", expected, omode="wb")])
--
2.27.0