Modem restart: load restarting.ha, which is what starts it
Lint / JS (eslint) (push) Successful in 8s
Lint / Python (flake8) (push) Successful in 1m2s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m3s
Lint / Python (flake8) (pull_request) Successful in 2m7s
Test / Python Tests (pytest) (push) Successful in 2m20s
Lint / JS (eslint) (pull_request) Successful in 15s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 57s
Test / Python Tests (pytest) (pull_request) Successful in 1m28s
Lint / JS (eslint) (push) Successful in 8s
Lint / Python (flake8) (push) Successful in 1m2s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m3s
Lint / Python (flake8) (pull_request) Successful in 2m7s
Test / Python Tests (pytest) (push) Successful in 2m20s
Lint / JS (eslint) (pull_request) Successful in 15s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 57s
Test / Python Tests (pytest) (pull_request) Successful in 1m28s
Tried on the real BGW320 (firmware 6.40.4): posting the Restart form only
answers 302 to /cgi-bin/restarting.ha, and the modem keeps running (its
uptime carried on). Loading that page, as a browser does, starts the
restart ("restarting ... approximately 155 seconds"). restart() now
follows the redirect and only reports 'accepted' when that page says it
is restarting.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c2ff072eb2
commit
3afd85626b
2 files changed
+35
-12
No files matched your search
+20
-6
@@ -525,22 +525,36 @@ class TestModemRestart:
|
||||
a.session.request = MagicMock(side_effect=gw)
|
||||
return a, gw
|
||||
|
||||
def test_posts_the_restart_form(self):
|
||||
REDIRECT = MagicMock(status_code=302, headers={'Location': '/cgi-bin/restarting.ha'}, text='')
|
||||
RESTARTING = MagicMock(status_code=200, text='<title>Restarting</title> Your AT&T BGW320-505 is restarting.')
|
||||
|
||||
def test_posts_the_form_then_loads_the_restarting_page(self):
|
||||
# Firmware 6.40: the post only redirects; loading restarting.ha starts the restart
|
||||
a, gw = self._admin()
|
||||
a.session.post = MagicMock(return_value=MagicMock(status_code=200, text='Restarting...'))
|
||||
a.session.post = MagicMock(return_value=self.REDIRECT)
|
||||
a.session.get = MagicMock(return_value=self.RESTARTING)
|
||||
assert a.restart() == 'accepted'
|
||||
data = a.session.post.call_args.kwargs['data']
|
||||
assert data == {'nonce': 'ffee00112233445566778899aabbccdd', 'Restart': 'Restart'}
|
||||
assert a.session.post.call_args.kwargs['data'] == {'nonce': 'ffee00112233445566778899aabbccdd',
|
||||
'Restart': 'Restart'}
|
||||
assert a.session.post.call_args.args[0].endswith('/cgi-bin/restart.ha')
|
||||
assert a.session.get.call_args.args[0].endswith('/cgi-bin/restarting.ha')
|
||||
assert ('POST', '/cgi-bin/login.ha') in gw.calls # logged in to read the form
|
||||
|
||||
def test_redirect_alone_is_not_a_restart(self):
|
||||
a, _ = self._admin()
|
||||
a.session.post = MagicMock(return_value=self.REDIRECT)
|
||||
a.session.get = MagicMock(return_value=MagicMock(status_code=200, text='<title>Device</title>'))
|
||||
with pytest.raises(modem.ModemDataInvalid, match='not started'):
|
||||
a.restart()
|
||||
|
||||
def test_connection_dropped_mid_restart(self):
|
||||
a, _ = self._admin()
|
||||
a.session.post = MagicMock(side_effect=requests.ConnectionError('reset'))
|
||||
a.session.post = MagicMock(return_value=self.REDIRECT)
|
||||
a.session.get = MagicMock(side_effect=requests.ConnectionError('reset'))
|
||||
assert a.restart() == 'unconfirmed'
|
||||
|
||||
def test_refused(self):
|
||||
a, _ = self._admin()
|
||||
a.session.post = MagicMock(return_value=MagicMock(status_code=200, text=LOGIN_FORM))
|
||||
with pytest.raises(modem.ModemDataInvalid, match='refused'):
|
||||
with pytest.raises(modem.ModemDataInvalid, match='not started'):
|
||||
a.restart()
|
||||
Reference in new issue
Block a user