Repository: postlund/pyatv
Pull request #1274 (2021-08-29 17:49:18)

conf: Add password to RAOP output
Relates to #1273

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



codecov[bot]: # [Codecov](https://codecov.io/gh/postlund/pyatv/pull/1274?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl) Report
> Merging [#1274](https://codecov.io/gh/postlund/pyatv/pull/1274?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl) (8ad5d6a) into [master](https://codecov.io/gh/postlund/pyatv/commit/c5513b3471767e4f359b9e55b54544f2c5643c4e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl) (c5513b3) will **decrease** coverage by `0.48%`.
> The diff coverage is `100.00%`.

> :exclamation: Current head 8ad5d6a differs from pull request most recent head 2badf5b. Consider uploading reports for the commit 2badf5b to get more accurate results
[![Impacted file tree graph](https://codecov.io/gh/postlund/pyatv/pull/1274/graphs/tree.svg?width=650&height=150&src=pr&token=wb6azJjRSY&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl)](https://codecov.io/gh/postlund/pyatv/pull/1274?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl)

```diff
@@            Coverage Diff             @@
##           master    #1274      +/-   ##
==========================================
- Coverage   95.27%   94.78%   -0.49%     
==========================================
  Files          59       59              
  Lines        6239     6209      -30     
==========================================
- Hits         5944     5885      -59     
- Misses        295      324      +29     
```


| [Impacted Files](https://codecov.io/gh/postlund/pyatv/pull/1274?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/conf.py](https://codecov.io/gh/postlund/pyatv/pull/1274/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl#diff-cHlhdHYvY29uZi5weQ==) | `99.22% <100.00%> (+0.01%)` | :arrow_up: |
| [pyatv/raop/raop.py](https://codecov.io/gh/postlund/pyatv/pull/1274/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl#diff-cHlhdHYvcmFvcC9yYW9wLnB5) | `85.18% <0.00%> (-4.18%)` | :arrow_down: |
| [pyatv/mrp/protocol.py](https://codecov.io/gh/postlund/pyatv/pull/1274/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl#diff-cHlhdHYvbXJwL3Byb3RvY29sLnB5) | `92.30% <0.00%> (-2.80%)` | :arrow_down: |
| [pyatv/raop/audio\_source.py](https://codecov.io/gh/postlund/pyatv/pull/1274/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl#diff-cHlhdHYvcmFvcC9hdWRpb19zb3VyY2UucHk=) | `86.87% <0.00%> (-2.50%)` | :arrow_down: |
| [pyatv/mrp/connection.py](https://codecov.io/gh/postlund/pyatv/pull/1274/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl#diff-cHlhdHYvbXJwL2Nvbm5lY3Rpb24ucHk=) | `81.05% <0.00%> (-2.29%)` | :arrow_down: |
| [pyatv/support/net.py](https://codecov.io/gh/postlund/pyatv/pull/1274/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl#diff-cHlhdHYvc3VwcG9ydC9uZXQucHk=) | `91.66% <0.00%> (-1.67%)` | :arrow_down: |
| [pyatv/support/mdns.py](https://codecov.io/gh/postlund/pyatv/pull/1274/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl#diff-cHlhdHYvc3VwcG9ydC9tZG5zLnB5) | `90.14% <0.00%> (-0.71%)` | :arrow_down: |
| [pyatv/support/http.py](https://codecov.io/gh/postlund/pyatv/pull/1274/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl#diff-cHlhdHYvc3VwcG9ydC9odHRwLnB5) | `92.92% <0.00%> (-0.70%)` | :arrow_down: |
| [pyatv/mrp/pairing.py](https://codecov.io/gh/postlund/pyatv/pull/1274/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl#diff-cHlhdHYvbXJwL3BhaXJpbmcucHk=) | `97.61% <0.00%> (-0.11%)` | :arrow_down: |
| [pyatv/companion/connection.py](https://codecov.io/gh/postlund/pyatv/pull/1274/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl#diff-cHlhdHYvY29tcGFuaW9uL2Nvbm5lY3Rpb24ucHk=) | `89.09% <0.00%> (-0.10%)` | :arrow_down: |
| ... and [11 more](https://codecov.io/gh/postlund/pyatv/pull/1274/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/postlund/pyatv/pull/1274?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/postlund/pyatv/pull/1274?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl). Last update [c5513b3...2badf5b](https://codecov.io/gh/postlund/pyatv/pull/1274?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Pierre+St%C3%A5hl).


Patch:
diff --git a/docs/api/pyatv/conf.html b/docs/api/pyatv/conf.html
index bd5b2a4f..7fa19e66 100644
--- a/docs/api/pyatv/conf.html
+++ b/docs/api/pyatv/conf.html
@@ -64,7 +64,7 @@ possible to manually create a configuration, but generally scanning for devices
 provide configurations for you.</p>
 <p>For a configuration to be usable ("ready") it must have either a <code>DMAP</code> or <code>MRP</code>
 configuration (or both), as connecting to plain <code>AirPlay</code> devices it not supported.</p>
-<div class="git-link-div"><a href="https://github.com/postlund/pyatv/blob/master/pyatv/conf.py#L1-L293" class="git-link">Browse git</a></div>
+<div class="git-link-div"><a href="https://github.com/postlund/pyatv/blob/master/pyatv/conf.py#L1-L297" class="git-link">Browse git</a></div>
 </section>
 <section>
 </section>
@@ -267,7 +267,7 @@ returned.</p></section>
 <dd>
 <section class="desc"><p>Representation of an RAOP service.</p>
 <p>Initialize a new RaopService.</p></section>
-<div class="git-link-div"><a href="https://github.com/postlund/pyatv/blob/master/pyatv/conf.py#L279-L293" class="git-link">Browse git</a></div>
+<div class="git-link-div"><a href="https://github.com/postlund/pyatv/blob/master/pyatv/conf.py#L279-L297" class="git-link">Browse git</a></div>
 <h3>Ancestors</h3>
 <ul class="hlist">
 <li><a title="pyatv.interface.BaseService" href="interface#pyatv.interface.BaseService">BaseService</a></li>
diff --git a/pyatv/conf.py b/pyatv/conf.py
index ebb514e2..b15db36a 100644
--- a/pyatv/conf.py
+++ b/pyatv/conf.py
@@ -192,8 +192,8 @@ class AppleTV:
     def __str__(self) -> str:
         """Return a string representation of this object."""
         device_info = self.device_info
-        services = "\n".join([" - {0}".format(s) for s in self._services.values()])
-        identifiers = "\n".join([" - {0}".format(x) for x in self.all_identifiers])
+        services = "\n".join([f" - {s}" for s in self._services.values()])
+        identifiers = "\n".join([f" - {x}" for x in self.all_identifiers])
         return (
             f"       Name: {self.name}\n"
             f"   Model/SW: {device_info}\n"
@@ -291,3 +291,7 @@ class RaopService(BaseService):
         super().__init__(identifier, Protocol.RAOP, port, properties)
         self.credentials = credentials
         self.password = password
+
+    def __str__(self) -> str:
+        """Return a string representation of this object."""
+        return super().__str__() + f", Password: {self.password}"


Test patch:
diff --git a/tests/test_conf.py b/tests/test_conf.py
index 9192a7a0..2dfcd66e 100644
--- a/tests/test_conf.py
+++ b/tests/test_conf.py
@@ -17,6 +17,7 @@ IDENTIFIER_2 = "id2"
 IDENTIFIER_3 = "id3"
 IDENTIFIER_4 = "id4"
 CREDENTIALS_1 = "cred1"
+PASSWORD_1 = "password1"
 
 MRP_PROPERTIES = {
     "systembuildversion": "17K795",
@@ -277,3 +278,9 @@ def test_to_str(config):
     assert str(PORT_2) in output
     assert "3689" in output
     assert "Deep Sleep: True" in output
+
+
+def test_raop_password_in_str(config):
+    config.add_service(conf.RaopService(IDENTIFIER_1, password=PASSWORD_1))
+
+    assert PASSWORD_1 in str(config)