HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/pkgs/rope-1.12.0-py312haa95532_0/info/test/ropetest/versioningtest.py
import secrets
from unittest.mock import patch

from rope.base import versioning


def test_calculate_version_hash(project):
    version_hash = versioning.calculate_version_hash(project)
    assert isinstance(version_hash, str)


def test_version_hash_is_constant(project):
    version_hash_1 = versioning.calculate_version_hash(project)
    version_hash_2 = versioning.calculate_version_hash(project)
    assert version_hash_1 == version_hash_2


def test_version_hash_varies_on_rope_version(project):
    actual_version_hash = versioning.calculate_version_hash(project)
    with patch("rope.VERSION", "1.0.0"):
        patched_version_hash = versioning.calculate_version_hash(project)
    assert actual_version_hash != patched_version_hash


def test_version_hash_varies_on_user_preferences(project):
    actual_version_hash = versioning.calculate_version_hash(project)
    assert project.prefs.get("automatic_soa") is False
    project.prefs.set("automatic_soa", True)
    patched_version_hash = versioning.calculate_version_hash(project)
    assert actual_version_hash != patched_version_hash


def test_version_hash_varies_on_get_file_content(project):
    actual_version_hash = versioning.calculate_version_hash(project)
    with patch("rope.base.versioning._get_file_content", return_value=secrets.token_hex()):
        patched_version_hash = versioning.calculate_version_hash(project)
    assert actual_version_hash != patched_version_hash