test_build.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:shub-image 作者: scrapinghub 项目源码 文件源码
def test_cli(self, test_mock, mocked_method):
        mocked = mock.MagicMock()
        mocked.build.return_value = [
            {"stream": "all is ok"},
            {"stream": "Successfully built 12345"}]
        mocked_method.return_value = mocked
        with FakeProjectDirectory() as tmpdir:
            add_scrapy_fake_config(tmpdir)
            add_sh_fake_config(tmpdir)
            add_fake_dockerfile(tmpdir)
            setup_py_path = os.path.join(tmpdir, 'setup.py')
            assert not os.path.isfile(setup_py_path)
            runner = CliRunner()
            result = runner.invoke(cli, ["dev", "-d"])
            assert result.exit_code == 0
            mocked.build.assert_called_with(
                decode=True, path=tmpdir, tag='registry/user/project:1.0')
            assert os.path.isfile(setup_py_path)
            test_mock.assert_called_with("dev", None)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号