Skip to content

Commit c70ebf6

Browse files
committed
Added tests and no coverage pragmas
1 parent 5c8faed commit c70ebf6

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

src/briefcase/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,13 @@ def validate_document_type_config(document_type_id, document_type):
146146
f"The URL associated with document type {document_type_id!r} is invalid: {e}"
147147
)
148148

149-
if sys.platform == "darwin":
149+
if sys.platform == "darwin": # pragma: no-cover-if-not-macos
150150
from briefcase.platforms.macOS.utils import mime_type_to_UTI
151151

152152
macOS = document_type.setdefault("macOS", {})
153153
if (UTI := mime_type_to_UTI(document_type.get("mime_type", None))) is not None:
154154
macOS.setdefault("LSItemContentType", UTI)
155155
macOS.setdefault("LSHandlerRank", "Alternate")
156-
macOS.setdefault("UTTypeConformsTo", ["public.xyz"])
157156
else:
158157
# LSItemContentType will default to bundle.app_name.document_type_id
159158
# in the Info.plist template if it is not provided.

src/briefcase/platforms/macOS/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def merge_app_packages(
276276
self.console.info("No libraries require merging.")
277277

278278

279-
def mime_type_to_UTI(mime_type: str) -> str | None:
279+
def mime_type_to_UTI(mime_type: str) -> str | None: # pragma: no-cover-if-not-macos
280280
"""Convert a MIME type to a Uniform Type Identifier (UTI).
281281
282282
This function reads the system's CoreTypes Info.plist file to determine the

tests/config/test_document_type_config.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,26 @@ def test_validate_document_invalid_extension(invalid_extension, valid_document):
160160
match=r"The extension provided for document type .* is not alphanumeric.",
161161
):
162162
validate_document_type_config("ext", valid_document)
163+
164+
165+
def test_document_type_macOS_config_with_mimetype_single(valid_document):
166+
"""Valid document types don't raise an exception when validated."""
167+
valid_document["mime_type"] = "application/pdf"
168+
validate_document_type_config("ext", valid_document)
169+
assert "LSItemContentType" in valid_document["macOS"].keys()
170+
assert valid_document["macOS"]["LSItemContentType"] == "com.adobe.pdf"
171+
172+
173+
def test_document_type_macOS_config_with_mimetype_list(valid_document):
174+
"""Valid document types don't raise an exception when validated."""
175+
valid_document["mime_type"] = "text/vcard"
176+
validate_document_type_config("ext", valid_document)
177+
assert "LSItemContentType" in valid_document["macOS"].keys()
178+
assert valid_document["macOS"]["LSItemContentType"] == "public.vcard"
179+
180+
181+
def test_document_type_macOS_config_with_unknown_mimetype(valid_document):
182+
"""Valid document types don't raise an exception when validated."""
183+
valid_document["mime_type"] = "custom/mytype"
184+
validate_document_type_config("ext", valid_document)
185+
assert "LSItemContentType" not in valid_document["macOS"].keys()

0 commit comments

Comments
 (0)