Repository: postlund/pyatv
Pull request #2068 (2023-06-26 04:36:12)

airplay: Disable AirPlay for macOS
Pairing does not work towards macOS, so set Unsupported as pairing requirement until I figure that out.

<a href="https://gitpod.io/#https://github.com/postlund/pyatv/pull/2068"><img src="https://gitpod.io/button/open-in-gitpod.svg"/></a>



codecov[bot]: ## [Codecov](https://app.codecov.io/gh/postlund/pyatv/pull/2068?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl) Report
Patch coverage: **`100.00`**% and project coverage change: **`-0.25`** :warning:
> Comparison is base [(`dd773cc`)](https://app.codecov.io/gh/postlund/pyatv/commit/dd773cc4dffde2accb591236db985171961f3f24?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl) 88.82% compared to head [(`3826968`)](https://app.codecov.io/gh/postlund/pyatv/pull/2068?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl) 88.57%.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #2068      +/-   ##
==========================================
- Coverage   88.82%   88.57%   -0.25%     
==========================================
  Files         163      163              
  Lines       10841    10844       +3     
==========================================
- Hits         9629     9605      -24     
- Misses       1212     1239      +27     
```


| [Impacted Files](https://app.codecov.io/gh/postlund/pyatv/pull/2068?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl) | Coverage Δ | |
|---|---|---|
| [pyatv/protocols/airplay/utils.py](https://app.codecov.io/gh/postlund/pyatv/pull/2068?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl#diff-cHlhdHYvcHJvdG9jb2xzL2FpcnBsYXkvdXRpbHMucHk=) | `87.59% <100.00%> (+0.27%)` | :arrow_up: |

... and [5 files with indirect coverage changes](https://app.codecov.io/gh/postlund/pyatv/pull/2068/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl)


</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/postlund/pyatv/pull/2068?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl).


Patch:
diff --git a/pyatv/protocols/airplay/utils.py b/pyatv/protocols/airplay/utils.py
index bf10d0af..3a56ab48 100644
--- a/pyatv/protocols/airplay/utils.py
+++ b/pyatv/protocols/airplay/utils.py
@@ -29,6 +29,8 @@ DBFS_MAX = 0.0
 PERCENTAGE_MIN = 0.0
 PERCENTAGE_MAX = 100.0
 
+UNSUPPORTED_MODELS = [r"^Mac\d+,\d+$"]
+
 
 class AirPlayMajorVersion(Enum):
     """Major AirPlay protocol version."""
@@ -243,6 +245,13 @@ def update_service_details(service: MutableService):
         # Access control might say that pairing is not possible, e.g. only devices
         # belonging to the same home (not supported by pyatv)
         service.pairing = PairingRequirement.Disabled
+    elif any(
+        re.match(model, service.properties.get("model", ""))
+        for model in UNSUPPORTED_MODELS
+    ):
+        # Set as "unsupported" for devices we know that pyatv does
+        # (yet) support.
+        service.pairing = PairingRequirement.Unsupported
     else:
         service.pairing = get_pairing_requirement(service)
 


Test patch:
diff --git a/tests/protocols/airplay/test_airplay.py b/tests/protocols/airplay/test_airplay.py
index 3dd7f02e..9b270a2f 100644
--- a/tests/protocols/airplay/test_airplay.py
+++ b/tests/protocols/airplay/test_airplay.py
@@ -111,6 +111,7 @@ async def test_service_info_password(airplay_props, mrp_props, requires_password
         ({"flags": "0x200"}, {}, PairingRequirement.Mandatory),
         ({"acl": "1"}, {}, PairingRequirement.Disabled),
         ({"acl": "1", "sf": "0x200"}, {}, PairingRequirement.Disabled),
+        ({"model": "Mac10,1"}, {}, PairingRequirement.Unsupported),
     ],
 )
 async def test_service_info_pairing(airplay_props, devinfo, pairing_req):