summaryrefslogtreecommitdiff
path: root/tests/unittests/test_data.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2015-01-22 18:38:30 -0500
committerBarry Warsaw <barry@python.org>2015-01-22 18:38:30 -0500
commit508670bdaf9545b6bcc8e2009e8bd3f08d6f8796 (patch)
tree613e6abbce7556f39ff2987bf7c4aa565b5a8a39 /tests/unittests/test_data.py
parentb3bbd3985a75d00115e1623dc1ebd4248a7024a6 (diff)
downloadvyos-cloud-init-508670bdaf9545b6bcc8e2009e8bd3f08d6f8796.tar.gz
vyos-cloud-init-508670bdaf9545b6bcc8e2009e8bd3f08d6f8796.zip
More test ports from mocker to mock.
Diffstat (limited to 'tests/unittests/test_data.py')
-rw-r--r--tests/unittests/test_data.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/tests/unittests/test_data.py b/tests/unittests/test_data.py
index 71e02e5d..7598837e 100644
--- a/tests/unittests/test_data.py
+++ b/tests/unittests/test_data.py
@@ -55,7 +55,6 @@ class TestConsumeUserData(helpers.FilesystemMockingTestCase):
helpers.FilesystemMockingTestCase.tearDown(self)
def _patchIn(self, root):
- self.restore()
self.patchOS(root)
self.patchUtils(root)
@@ -349,17 +348,17 @@ p: 1
data = "arbitrary text\n"
ci.datasource = FakeDataSource(data)
- mock_write = self.mocker.replace("cloudinit.util.write_file",
- passthrough=False)
- mock_write(ci.paths.get_ipath("cloud_config"), "", 0o600)
- self.mocker.replay()
+ with mock.patch('cloudinit.util.write_file') as mockobj:
+ log_file = self.capture_log(logging.WARNING)
+ ci.fetch()
+ ci.consume_data()
+ self.assertIn(
+ "Unhandled non-multipart (text/x-not-multipart) userdata:",
+ log_file.getvalue())
+
+ mockobj.assert_called_once_with(
+ ci.paths.get_ipath("cloud_config"), "", 0o600)
- log_file = self.capture_log(logging.WARNING)
- ci.fetch()
- ci.consume_data()
- self.assertIn(
- "Unhandled non-multipart (text/x-not-multipart) userdata:",
- log_file.getvalue())
def test_mime_gzip_compressed(self):
"""Tests that individual message gzip encoding works."""