Skip to content

Commit

Permalink
Merge pull request #30 from chemelli74/chemelli74-autoupdate
Browse files Browse the repository at this point in the history
build: prepare changes for pre-commit autoupdate
  • Loading branch information
chemelli74 authored Sep 19, 2023
2 parents bd13f25 + 3c1f163 commit 66ab16b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
4 changes: 1 addition & 3 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"projectOwner": "chemelli74",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"README.md"
],
"files": ["README.md"],
"imageSize": 80,
"commit": true,
"commitConvention": "angular",
Expand Down
17 changes: 9 additions & 8 deletions src/aiovodafone/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ async def _find_login_url(self) -> str:
reply_text = await reply.text()
soup = bs4.BeautifulSoup(reply_text, "html.parser")
meta_refresh = soup.find("meta", {"http-equiv": "Refresh"})
if meta_refresh is not None:
meta_content = meta_refresh["content"]
reply_url = urllib.parse.parse_qs(meta_content, separator="; ")["URL"][0]
if isinstance(meta_refresh, bs4.Tag) and "content" in meta_refresh:
meta_content = meta_refresh.get("content")
parsed_qs = urllib.parse.parse_qs(str(meta_content), separator="; ")
reply_url: str = parsed_qs["URL"][0]
redirect_url = urllib.parse.urlparse(reply_url)
if redirect_url.scheme != self.protocol:
self.protocol = redirect_url.scheme
Expand All @@ -101,7 +102,7 @@ async def _get_csrf_token(self, reply_text: str) -> None:
soup = bs4.BeautifulSoup(reply_text, "html.parser")
script_tag = soup.find("script", string=True)
try:
token = re.findall("(?<=csrf_token)|[^']+", script_tag.string)[1]
token = re.findall("(?<=csrf_token)|[^']+", str(script_tag))[1]
except IndexError:
raise ModelNotSupported
if not token:
Expand Down Expand Up @@ -141,11 +142,11 @@ async def _reset(self) -> bool:
"""Reset page content before loading."""

payload = {"chk_sys_busy": ""}
reply: aiohttp.ClientResponse = await self._post_page_result(
"/data/reset.json", payload, True
)
reply = await self._post_page_result("/data/reset.json", payload, True)
if isinstance(reply, aiohttp.ClientResponse):
return reply.status == 200

return reply.status == 200
return False

async def _login_json(self, username: str, password: str) -> bool:
"""Login via json page"""
Expand Down
14 changes: 7 additions & 7 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@


def test_objects_can_be_imported():
assert VodafoneStationDevice
assert VodafoneStationApi
assert VodafoneError
assert AlreadyLogged
assert CannotConnect
assert CannotAuthenticate
assert ModelNotSupported
assert type(VodafoneStationDevice)
assert type(VodafoneStationApi)
assert type(VodafoneError)
assert type(AlreadyLogged)
assert type(CannotConnect)
assert type(CannotAuthenticate)
assert type(ModelNotSupported)

0 comments on commit 66ab16b

Please sign in to comment.