[virt-tools-list] [virt-bootstrap] [PATCH v4 26/26] tests: FileSource for fmt='qcow2'

Radostin Stoyanov rstoyanov1 at gmail.com
Thu Aug 3 13:13:24 UTC 2017


---
 tests/test_file_source.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tests/test_file_source.py b/tests/test_file_source.py
index b850a7c..f649d3a 100644
--- a/tests/test_file_source.py
+++ b/tests/test_file_source.py
@@ -88,6 +88,36 @@ class TestFileSource(unittest.TestCase):
 
         m_untar.assert_called_once_with(m_self.path, dest, m_self.faster)
 
+    def test_unpack_to_qcow2(self):
+        """
+        Ensures that unpack() calls Build_QCOW2_Image() when the output
+        format is set to 'qcow2'.
+        """
+        patch_method = 'virtBootstrap.utils.Build_QCOW2_Image'
+
+        m_self = mock.Mock(spec=sources.FileSource)
+        m_self.progress = mock.Mock()
+        m_self.path = 'foo'
+        m_self.uid_map = 'uid_map'
+        m_self.gid_map = 'gid_map'
+        m_self.root_password = 'secret'
+        m_self.output_format = 'qcow2'
+        dest = 'bar'
+
+        with mock.patch('os.path.isfile') as m_isfile:
+            m_isfile.return_value = True
+            with mock.patch(patch_method) as m_Build_QCOW2_Image:
+                sources.FileSource.unpack(m_self, dest)
+
+        m_Build_QCOW2_Image.assert_called_once_with(
+            tar_files=[m_self.path],
+            dest=dest,
+            uid_map=m_self.uid_map,
+            gid_map=m_self.gid_map,
+            progress=m_self.progress,
+            root_password=m_self.root_password
+        )
+
     def _unpack_raise_error_test(self,
                                  output_format,
                                  side_effect=None,
-- 
2.13.3




More information about the virt-tools-list mailing list