Example #1
0
def test_check_package_identical_version(mocker):
    compare_content = mocker.patch(
        "raincoat.match.pypi.PyPIChecker.compare_contents")

    version = mocker.patch("raincoat.source.get_current_or_latest_version")
    version.return_value = (True, "1.2.3")

    checker = PyPIChecker()

    checker.check_package("umbrella", "1.2.3", [get_match()])

    assert len(checker.errors) == 0
    assert compare_content.mock_calls == []
Example #2
0
def test_check_package_not_installed(mocker):
    compare_content = mocker.patch(
        "raincoat.match.pypi.PyPIChecker.compare_contents")

    source = mocker.patch("raincoat.match.pypi.source")

    source.get_current_or_latest_version.return_value = (False, "1.2.3")
    source.open_downloaded.return_value = {"file_a.py": "code"}
    source.open_installed.return_value = {"file_a.py": "code"}

    checker = PyPIChecker()

    with checker.cleaner_ctx():
        checker.check_package("umbrella", "1.2.2", [get_match()])

    assert len(source.download_package.mock_calls) == 2
    assert len(source.open_downloaded.mock_calls) == 2
    assert len(source.open_installed.mock_calls) == 0
    assert len(checker.errors) == 0
    assert compare_content.mock_calls == []
Example #3
0
def test_check_package_installed_no_fast_escape(mocker):
    compare_content = mocker.patch(
        "raincoat.match.pypi.PyPIChecker.compare_contents")

    source = mocker.patch("raincoat.match.pypi.source")

    source.get_current_or_latest_version.return_value = (True, "1.2.3")
    source.open_downloaded.return_value = {"file_a.py": "code"}
    source.open_installed.return_value = {"file_a.py": "code2"}

    match = get_match()

    checker = PyPIChecker()
    with checker.cleaner_ctx():
        checker.check_package("umbrella", "1.2.2", [match])

    assert len(source.download_package.mock_calls) == 1
    assert len(source.open_downloaded.mock_calls) == 1
    assert len(source.open_installed.mock_calls) == 1
    assert len(checker.errors) == 0
    assert compare_content.mock_calls == [
        mock.call({"file_a.py": "code"}, {"file_a.py": "code2"}, [match])
    ]