File: conftest.py

package info (click to toggle)
python-briefcase 0.3.25-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,596 kB
  • sloc: python: 62,519; makefile: 60
file content (55 lines) | stat: -rw-r--r-- 1,425 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os
import platform
import shutil
import sys
from unittest.mock import MagicMock

import pytest

from briefcase.config import AppConfig
from briefcase.integrations.base import ToolCache
from briefcase.integrations.file import File
from briefcase.integrations.subprocess import Subprocess


@pytest.fixture
def mock_tools(dummy_console, tmp_path) -> ToolCache:
    mock_tools = ToolCache(
        console=dummy_console,
        base_path=tmp_path / "tools",
        home_path=tmp_path / "home",
    )

    # Mock stdlib tools
    mock_tools.os = MagicMock(spec_set=os)
    mock_tools.platform = MagicMock(spec_set=platform)
    mock_tools.shutil = MagicMock(spec_set=shutil)
    mock_tools.sys = MagicMock(spec_set=sys)

    # Mock an empty environment
    mock_tools.os.environ = {}

    # Create base directories
    mock_tools.base_path.mkdir(parents=True)
    mock_tools.home_path.mkdir(parents=True)

    # Make File and Subprocess always available
    File.verify(tools=mock_tools)
    Subprocess.verify(tools=mock_tools)

    return mock_tools


@pytest.fixture
def first_app_config():
    return AppConfig(
        app_name="first-app",
        project_name="First Project",
        formal_name="First App",
        author="Megacorp",
        bundle="com.example",
        version="0.0.1",
        description="The first simple app",
        sources=["src/first_app"],
        license={"file": "LICENSE"},
    )