예제 #1
0
    def test__download_image_from_url_success(self, mock_get, mock_open):
        self.mock_isfile.return_value = False
        img_path = os.path.join(self.context.data_dir, "foo")
        mock_get.return_value.iter_content.return_value = "data"

        config._download_image(img_path)
        mock_get.assert_called_once_with(CONF.tempest.img_url, stream=True)
        mock_open.assert_called_once_with(img_path, "wb")
        mock_open().write.assert_has_calls([mock.call("d"),
                                            mock.call("a"),
                                            mock.call("t"),
                                            mock.call("a")])
예제 #2
0
    def test__download_image_from_glance(self, mock_open):
        self.mock_isfile.return_value = False
        img_path = os.path.join(self.context.data_dir, "foo")
        img = mock.MagicMock()
        img.data.return_value = "data"

        config._download_image(img_path, img)
        mock_open.assert_called_once_with(img_path, "wb")
        mock_open().write.assert_has_calls([mock.call("d"),
                                            mock.call("a"),
                                            mock.call("t"),
                                            mock.call("a")])
예제 #3
0
    def test__download_image_from_url_success(self, mock_get, mock_open):
        self.mock_isfile.return_value = False
        img_path = os.path.join(self.context.data_dir, "foo")
        mock_get.return_value.iter_content.return_value = "data"

        config._download_image(img_path)
        mock_get.assert_called_once_with(CONF.tempest.img_url, stream=True)
        mock_open.assert_called_once_with(img_path, "wb")
        mock_open().write.assert_has_calls(
            [mock.call("d"),
             mock.call("a"),
             mock.call("t"),
             mock.call("a")])
예제 #4
0
    def test__download_image_from_glance(self, mock_open):
        self.mock_isfile.return_value = False
        img_path = os.path.join(self.context.data_dir, "foo")
        img = mock.MagicMock()
        img.data.return_value = "data"

        config._download_image(img_path, img)
        mock_open.assert_called_once_with(img_path, "wb")
        mock_open().write.assert_has_calls(
            [mock.call("d"),
             mock.call("a"),
             mock.call("t"),
             mock.call("a")])