Repository: postlund/pyatv
Pull request #2047 (2023-06-13 11:59:10)

add FeatureName.TextFocusState to supported features for Companion
I forgot to add this in #2031.

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/postlund/pyatv/pull/2047?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 has no change and project coverage change: **`-0.17`** :warning:
> Comparison is base [(`bb20742`)](https://app.codecov.io/gh/postlund/pyatv/commit/bb207427963e35b6a672b3c32b1dcceb12dc093c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl) 89.22% compared to head [(`a887f86`)](https://app.codecov.io/gh/postlund/pyatv/pull/2047?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl) 89.06%.

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


```diff
@@            Coverage Diff             @@
##           master    #2047      +/-   ##
==========================================
- Coverage   89.22%   89.06%   -0.17%     
==========================================
  Files         158      158              
  Lines       10407    10407              
==========================================
- Hits         9286     9269      -17     
- Misses       1121     1138      +17     
```


| [Impacted Files](https://app.codecov.io/gh/postlund/pyatv/pull/2047?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/companion/\_\_init\_\_.py](https://app.codecov.io/gh/postlund/pyatv/pull/2047?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl#diff-cHlhdHYvcHJvdG9jb2xzL2NvbXBhbmlvbi9fX2luaXRfXy5weQ==) | `97.65% <ø> (ø)` | |

... and [3 files with indirect coverage changes](https://app.codecov.io/gh/postlund/pyatv/pull/2047/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/2047?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).

postlund: Yeah, that's right. I think there should be some modifications for these constants regarding the Features interface. I probably missed that in the previous review, can you take a look at that?
michalmo: I'm not sure I understand. It looks like all the other protocols just fall back to Unsupported or Unavailable for these new feature constants, and this is the only one I forgot to add for Companion.

Can you explain what you have in mind?
postlund: > I'm not sure I understand. It looks like all the other protocols just fall back to Unsupported or Unavailable for these new feature constants, and this is the only one I forgot to add for Companion.
> 
> Can you explain what you have in mind?

All features we add needs to have some kind of state support. In case of companion we always know that the feature exists and are available (with media flags being an exception, since we get updates for play, pause, etc.) so we should make sure we return "available" in that case. Simply add feature to this list (you should probably add for output devices as well):

https://github.com/postlund/pyatv/blob/254694c9b9a304bc5161437d1c99952e0a782755/pyatv/protocols/companion/__init__.py#L107

And update corresponding test to verify it. Should be a list in the test as well.
michalmo: OK. I added the features as supported previously (except FeatureName.TextFocusState). Just added a commit with tests for all the new ones too.

Patch:
diff --git a/pyatv/protocols/companion/__init__.py b/pyatv/protocols/companion/__init__.py
index 886f8090..a2de1702 100644
--- a/pyatv/protocols/companion/__init__.py
+++ b/pyatv/protocols/companion/__init__.py
@@ -130,6 +130,7 @@ SUPPORTED_FEATURES = set(
         FeatureName.ChannelDown,
         FeatureName.Screensaver,
         # Keyboard interface
+        FeatureName.TextFocusState,
         FeatureName.TextGet,
         FeatureName.TextClear,
         FeatureName.TextAppend,


Test patch:
diff --git a/tests/protocols/companion/test_companion_functional.py b/tests/protocols/companion/test_companion_functional.py
index bce6e39c..8df08b9b 100644
--- a/tests/protocols/companion/test_companion_functional.py
+++ b/tests/protocols/companion/test_companion_functional.py
@@ -41,6 +41,13 @@ MEDIA_CONTROL_FEATURES = [
 
 ALWAYS_PRESENT_FEATURES = [
     FeatureName.Screensaver,
+    FeatureName.AccountList,
+    FeatureName.SwitchAccount,
+    FeatureName.TextFocusState,
+    FeatureName.TextGet,
+    FeatureName.TextClear,
+    FeatureName.TextAppend,
+    FeatureName.TextSet,
 ]
 
 pytestmark = pytest.mark.asyncio
diff --git a/tests/protocols/mrp/test_mrp_functional.py b/tests/protocols/mrp/test_mrp_functional.py
index 8f814304..f7650872 100644
--- a/tests/protocols/mrp/test_mrp_functional.py
+++ b/tests/protocols/mrp/test_mrp_functional.py
@@ -372,6 +372,10 @@ class MRPFunctionalTest(common_functional_tests.CommonFunctionalTests):
             FeatureName.TurnOn,
             FeatureName.TurnOff,
             FeatureName.PowerState,
+            FeatureName.OutputDevices,
+            FeatureName.AddOutputDevices,
+            FeatureName.RemoveOutputDevices,
+            FeatureName.SetOutputDevices,
         )
 
     async def test_features_artwork(self):