File: test_SigningIdentity.py

package info (click to toggle)
python-briefcase 0.3.25-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 7,596 kB
  • sloc: python: 62,519; makefile: 60
file content (53 lines) | stat: -rw-r--r-- 1,575 bytes parent folder | download | duplicates (2)
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
import pytest

from briefcase.exceptions import BriefcaseCommandError
from briefcase.platforms.macOS import SigningIdentity


@pytest.mark.parametrize(
    "identity_id, identity_name, team_id",
    [
        ("CAFEBEEF", "Developer ID Application: Jane Developer (DEADBEEF)", "DEADBEEF"),
        (
            "CAFEBEEF",
            "Developer ID Application: Edwin (Buzz) Aldrin (DEADBEEF)",
            "DEADBEEF",
        ),
    ],
)
def test_identity(identity_id, identity_name, team_id):
    """A signing identity can be created."""
    identity = SigningIdentity(id=identity_id, name=identity_name)
    assert identity.id == identity_id
    assert identity.name == identity_name
    assert identity.team_id == team_id
    assert not identity.is_adhoc
    assert repr(identity) == f"<SigningIdentity id={identity_id}>"


@pytest.mark.parametrize(
    "identity_name",
    [
        "Developer ID Application: Jane Developer",
        "DEADBEEF",
    ],
)
def test_bad_identity(identity_name):
    """Creating a bad identity raises an error."""
    with pytest.raises(
        BriefcaseCommandError,
        match=r"Couldn't extract Team ID from signing identity",
    ):
        SigningIdentity(id="CAFEBEEF", name=identity_name)


def test_adhoc_identity():
    """An ad-hoc identity can be created."""
    adhoc = SigningIdentity()
    assert adhoc.id == "-"
    assert (
        adhoc.name
        == "Ad-hoc identity. The resulting package will run but cannot be re-distributed."
    )
    assert adhoc.is_adhoc
    assert repr(adhoc) == "<AdhocSigningIdentity>"