Ejemplo n.º 1
0
def test_run(mocker):
    hook = GenerateRequirementsInFileHook()
    mocker.patch("os.getcwd", return_value="/path/to/project")
    mocker.patch.object(hook,
                        "_render_requirements_file",
                        return_value=["requirements_file_mocked_content"])
    open_mock = mocker.patch('builtins.open', mocker.mock_open())

    hook.run()

    open_mock.assert_called_once_with("/path/to/project/api/requirements.in",
                                      "w+")
    handle_open_mock = open_mock()
    handle_open_mock.writelines.assert_called_once_with(
        ["requirements_file_mocked_content"])
Ejemplo n.º 2
0
def test_run(mocker):
    hook = GenerateRequirementsInFileHook()
    mocker.patch("os.getcwd", return_value="/path/to/project")
    mocked_render_requirements_build_file = mocker.patch.object(
        hook, "_render_requirements_build_file", return_value=["build", "content"]
    )
    mocked_render_requirements_dev_file = mocker.patch.object(
        hook, "_render_requirements_dev_file", return_value=["dev", "content"]
    )
    mocked_write_requirements_build_file = mocker.patch.object(hook, "_write_requirements_build_file")
    mocked_write_requirements_dev_file = mocker.patch.object(hook, "_write_requirements_dev_file")

    hook.run()

    mocked_render_requirements_build_file.assert_called_once()
    mocked_write_requirements_build_file.assert_called_once_with(["build", "content"])
    mocked_render_requirements_dev_file.assert_called_once()
    mocked_write_requirements_dev_file.assert_called_once_with(["dev", "content"])