[virt-bootstrap] [PATCH v3 24/24] tests: FileSource for fmt='qcow2'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 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..074a613 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,
+            progress=m_self.progress,
+            uid_map=m_self.uid_map,
+            gid_map=m_self.gid_map,
+            root_password=m_self.root_password
+        )
+
     def _unpack_raise_error_test(self,
                                  output_format,
                                  side_effect=None,
-- 
2.13.3

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list



[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux