diff options
author | Radostin Stoyanov <rstoyanov1@gmail.com> | 2017-08-03 14:13:04 +0100 |
---|---|---|
committer | Radostin Stoyanov <rstoyanov1@gmail.com> | 2017-08-03 14:29:45 +0100 |
commit | b3023c77387b6e738011eef7def6e04d081d19f2 (patch) | |
tree | 16ef6eaa1303cda83a556d78b05059b888f7c04e /tests/test_docker_source.py | |
parent | 29d66930f4f4772db12fa1fec9ad88b52901050a (diff) | |
download | virt-bootstrap.git-b3023c77387b6e738011eef7def6e04d081d19f2.tar.gz virt-bootstrap.git-b3023c77387b6e738011eef7def6e04d081d19f2.tar.xz virt-bootstrap.git-b3023c77387b6e738011eef7def6e04d081d19f2.zip |
Split 'sources' module into files
Improve readability by spliting the 'sources' module into separate
files. Each file contains only one class.
In addition update the mock statements in the unit tests to match these
changes.
Add recursive-include in MANIFEST.in to include virtBootstrap.sources
module.
Update the unit tests to match these changes.
Diffstat (limited to 'tests/test_docker_source.py')
-rw-r--r-- | tests/test_docker_source.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/test_docker_source.py b/tests/test_docker_source.py index 4c52173..4859e1b 100644 --- a/tests/test_docker_source.py +++ b/tests/test_docker_source.py @@ -104,14 +104,14 @@ class TestDockerSource(unittest.TestCase): kwargs['username'] = 'test' with mock.patch('virtBootstrap.utils.get_image_dir'): - with mock.patch('virtBootstrap.sources.getpass') as m_getpass: - m_getpass.getpass.return_value = test_password + with mock.patch('getpass.getpass') as m_getpass: + m_getpass.return_value = test_password with mock.patch.multiple('virtBootstrap.sources.DockerSource', retrieve_layers_info=mock.DEFAULT, gen_valid_uri=mock.DEFAULT): src_instance = sources.DockerSource(**kwargs) - m_getpass.getpass.assert_called_once() + m_getpass.assert_called_once() self.assertIs(test_password, src_instance.password) ################################### @@ -375,7 +375,8 @@ class TestDockerSource(unittest.TestCase): """ m_self = mock.Mock(spec=sources.DockerSource) m_self.parse_output.return_value = parse_output_return - with mock.patch.multiple('virtBootstrap.sources.subprocess', + with mock.patch.multiple('virtBootstrap.sources.' + 'docker_source.subprocess', Popen=mock.DEFAULT, PIPE=mock.DEFAULT) as mocked: with mock.patch('virtBootstrap.utils.make_async') as m_make_async: @@ -402,7 +403,8 @@ class TestDockerSource(unittest.TestCase): Ensures that read_skopeo_progress() raise CalledProcessError when parse_output() returns false. """ - with self.assertRaises(sources.subprocess.CalledProcessError): + with self.assertRaises(sources.docker_source + .subprocess.CalledProcessError): self._mock_read_skopeo_progress('test', False) ################################### @@ -587,7 +589,7 @@ class TestDockerSource(unittest.TestCase): for fmt, patch_mthd in zip(output_formats, patch_methods): m_self = self._mock_docker_source() m_self.no_cache = True - with mock.patch('virtBootstrap.sources.shutil.rmtree') as m_shutil: + with mock.patch('shutil.rmtree') as m_shutil: self._unpack_test_fmt(fmt, patch_mthd, m_self=m_self) m_shutil.assert_called_once_with(m_self.images_dir) |