Example #1
0
    def test__create_root_fs(self, mkdir_mock, cp_mock, open_mock):
        files_info = {'a1': 'b1', 'a2': 'b2', 'a3': 'sub_dir/b3', b'a4': 'b4'}

        images._create_root_fs('root_dir', files_info)

        cp_mock.assert_any_call('a1', 'root_dir/b1')
        cp_mock.assert_any_call('a2', 'root_dir/b2')
        cp_mock.assert_any_call('a3', 'root_dir/sub_dir/b3')

        open_mock.assert_called_once_with('root_dir/b4', 'wb')
        fp = open_mock.return_value.__enter__.return_value
        fp.write.assert_called_once_with(b'a4')

        mkdir_mock.assert_any_call('root_dir', exist_ok=True)
        mkdir_mock.assert_any_call('root_dir/sub_dir', exist_ok=True)
Example #2
0
    def test__create_root_fs(self, path_exists_mock, dirname_mock, mkdir_mock, cp_mock):

        path_exists_mock_func = lambda path: path == "root_dir"

        files_info = {"a1": "b1", "a2": "b2", "a3": "sub_dir/b3"}

        path_exists_mock.side_effect = path_exists_mock_func
        dirname_mock.side_effect = iter(["root_dir", "root_dir", "root_dir/sub_dir", "root_dir/sub_dir"])
        images._create_root_fs("root_dir", files_info)
        cp_mock.assert_any_call("a1", "root_dir/b1")
        cp_mock.assert_any_call("a2", "root_dir/b2")
        cp_mock.assert_any_call("a3", "root_dir/sub_dir/b3")

        path_exists_mock.assert_any_call("root_dir/sub_dir")
        dirname_mock.assert_any_call("root_dir/b1")
        dirname_mock.assert_any_call("root_dir/b2")
        dirname_mock.assert_any_call("root_dir/sub_dir/b3")
        mkdir_mock.assert_called_once_with("root_dir/sub_dir")
Example #3
0
    def test__create_root_fs(self, path_exists_mock, dirname_mock, mkdir_mock,
                             cp_mock):

        path_exists_mock_func = lambda path: path == 'root_dir'

        files_info = {'a1': 'b1', 'a2': 'b2', 'a3': 'sub_dir/b3'}

        path_exists_mock.side_effect = path_exists_mock_func
        dirname_mock.side_effect = iter(
            ['root_dir', 'root_dir', 'root_dir/sub_dir', 'root_dir/sub_dir'])
        images._create_root_fs('root_dir', files_info)
        cp_mock.assert_any_call('a1', 'root_dir/b1')
        cp_mock.assert_any_call('a2', 'root_dir/b2')
        cp_mock.assert_any_call('a3', 'root_dir/sub_dir/b3')

        path_exists_mock.assert_any_call('root_dir/sub_dir')
        dirname_mock.assert_any_call('root_dir/b1')
        dirname_mock.assert_any_call('root_dir/b2')
        dirname_mock.assert_any_call('root_dir/sub_dir/b3')
        mkdir_mock.assert_called_once_with('root_dir/sub_dir')
Example #4
0
    def test__create_root_fs(self, path_exists_mock,
                            dirname_mock, mkdir_mock, cp_mock):

        path_exists_mock_func = lambda path: path == 'root_dir'

        files_info = {
                'a1': 'b1',
                'a2': 'b2',
                'a3': 'sub_dir/b3'}

        path_exists_mock.side_effect = path_exists_mock_func
        dirname_mock.side_effect = ['root_dir', 'root_dir',
                                    'root_dir/sub_dir', 'root_dir/sub_dir']
        images._create_root_fs('root_dir', files_info)
        cp_mock.assert_any_call('a1', 'root_dir/b1')
        cp_mock.assert_any_call('a2', 'root_dir/b2')
        cp_mock.assert_any_call('a3', 'root_dir/sub_dir/b3')

        path_exists_mock.assert_any_call('root_dir/sub_dir')
        dirname_mock.assert_any_call('root_dir/b1')
        dirname_mock.assert_any_call('root_dir/b2')
        dirname_mock.assert_any_call('root_dir/sub_dir/b3')
        mkdir_mock.assert_called_once_with('root_dir/sub_dir')