from pathlib import Path import pytest from losoup.file_operations.local_files import LocalFile from losoup.models import GithubSoftware, Asset from losoup.cvs.github import GithubConnector from losoup.cvs.github_settings import GithubSettings current_dir = Path(__file__).parent.absolute() dotenv = current_dir / "test.env" @pytest.fixture def github_settings(): return GithubSettings(_env_file=dotenv) @pytest.fixture def github_connector(github_settings): return GithubConnector(github_settings) @pytest.fixture def keepassxc(): return GithubSoftware( name="KeepassXC", owner="keepassxreboot", repo="keepassxc", version="2.7.9", folder="~/Softwares", filenameFormat="KeePassXC-{{version}}-x86_64.AppImage", ) @pytest.fixture def latest_keepassxc(): return GithubSoftware( name="KeepassXC", owner="keepassxreboot", repo="keepassxc", version="latest", folder="~/Softwares", filenameFormat="KeePassXC-{{version}}-x86_64.AppImage", ) @pytest.fixture def keepassxc_not_present(): return GithubSoftware( name="KeepassXC", owner="keepassxreboot", repo="keepassxc", version="2.79", folder="~/Softwares", filenameFormat="KeePassXC-{{version}}-x86_64.AppImage", ) @pytest.fixture def local_file(keepassxc): return LocalFile(keepassxc) @pytest.fixture def local_file_not_present(keepassxc_not_present): return LocalFile(keepassxc_not_present) @pytest.fixture def software_to_update(): return GithubSoftware( name="KeepassXC", owner="keepassxreboot", repo="keepassxc", version="2.8.1", folder="~/Softwares", filenameFormat="KeePassXC-{{version}}-x86_64.AppImage", ) @pytest.fixture def software_up_to_date(keepassxc): return keepassxc @pytest.fixture def asset(): return Asset( name="KeePassXC-2.7.9-x86_64.AppImage.DIGEST", url="https://api.github.com/repos/keepassxreboot/keepassxc/releases/assets/1747" "89149", ) @pytest.fixture def keepassxc_digest(): return GithubSoftware( name="KeepassXC digest", owner="keepassxreboot", repo="keepassxc", version="2.7.7", folder="~/Softwares", filenameFormat="KeePassXC-{{version}}-x86_64.AppImage.DIGEST", ) @pytest.fixture def keepassxc_digest_file(keepassxc_digest): return LocalFile(keepassxc_digest) @pytest.fixture def asset_to_write(): return Asset( name="KeePassXC-2.7.7-x86_64.AppImage.DIGEST", url="https://api.github.com/repos/keepassxreboot/keepassxc/releases/assets/1747" "89149", content=b"2a868b681a8ec4e381ac14203aec3d80ff6fa7a535fa102265a3ec9329b4b846 Kee" b"PassXC-2.7.9-x86_64.AppImage\n", )