Cleaning up assorted automatic warnings.
This commit is contained in:
@@ -154,15 +154,16 @@ class VacBot(ClientXMPP):
|
||||
|
||||
def session_start(self, event):
|
||||
logging.debug("----------------- starting session ----------------")
|
||||
logging.debug("event = {}".format(event))
|
||||
self.ready_flag.set()
|
||||
|
||||
self.register_handler(Callback('clean report',
|
||||
MatchXPath('{jabber:client}iq/{com:ctl}query/{com:ctl}ctl[@td="CleanReport"]'),
|
||||
self.handle_clean_report))
|
||||
self.register_handler(Callback('clean report',
|
||||
self.register_handler(Callback('charge state',
|
||||
MatchXPath('{jabber:client}iq/{com:ctl}query/{com:ctl}ctl[@td="ChargeState"]'),
|
||||
self.handle_charge_report))
|
||||
self.register_handler(Callback('clean report',
|
||||
self.register_handler(Callback('battery info',
|
||||
MatchXPath('{jabber:client}iq/{com:ctl}query/{com:ctl}ctl[@td="BatteryInfo"]'),
|
||||
self.handle_battery_report))
|
||||
|
||||
@@ -213,7 +214,7 @@ class VacBot(ClientXMPP):
|
||||
action.wait_for_completion(self)
|
||||
|
||||
|
||||
class VacBotCommand():
|
||||
class VacBotCommand:
|
||||
def __init__(self, name, args, wait=None, terminal=False):
|
||||
self.name = name
|
||||
self.args = args
|
||||
@@ -316,13 +317,13 @@ def read_config():
|
||||
|
||||
|
||||
def write_config(config):
|
||||
parser = configparser.ConfigParser()
|
||||
with open(config_file(), 'w') as fp:
|
||||
for key in config:
|
||||
fp.write(key + '=' + config[key] + "\n")
|
||||
|
||||
|
||||
def current_country():
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
return requests.get('http://ipinfo.io/json').json()['country'].lower()
|
||||
except:
|
||||
@@ -414,6 +415,9 @@ def run(actions, charge, debug):
|
||||
click.echo("Not logged in. Do 'click login' first.")
|
||||
exit(1)
|
||||
|
||||
if debug:
|
||||
logging.debug("will run {}".format(actions))
|
||||
|
||||
if actions:
|
||||
config = read_config()
|
||||
api = EcoVacsAPI(config['device_id'], config['email'], config['password_hash'],
|
||||
|
||||
+4
-2
@@ -74,10 +74,12 @@ def test_should_run():
|
||||
count += 1
|
||||
assert_almost_equal(count, 9000, delta=200)
|
||||
|
||||
|
||||
def test_continent_for_country():
|
||||
assert_equal(continent_for_country('us'), 'na')
|
||||
assert_equal(continent_for_country('fr'), 'eu')
|
||||
|
||||
|
||||
def test_wrap_command():
|
||||
v = VacBot('20170101abcdefabcdefa', 'ecouser.net', 'abcdef12', 'A1b2C3d4efghijklmNOPQrstuvwxyz12',
|
||||
{"did": "E0000000001234567890", "class": "126", "nick": "bob"}, 'na')
|
||||
@@ -93,7 +95,7 @@ def test_model_variation():
|
||||
assert_true(re.search(r'to="E0000000001234567890@141.ecorobot.net/atom"', c))
|
||||
|
||||
|
||||
def test_main_api_called():
|
||||
def test_main_api_setup():
|
||||
with requests_mock.mock() as m:
|
||||
r1 = m.get(re.compile('user/login'),
|
||||
text='{"time": 1511200804243, "data": {"accessToken": "7a375650b0b1efd780029284479c4e41", "uid": "2017102559f0ee63c588d", "username": null, "email": "william-ecovacs@pota.to", "country": "us"}, "code": "0000", "msg": "X"}')
|
||||
@@ -101,7 +103,7 @@ def test_main_api_called():
|
||||
text='{"time": 1511200804607, "data": {"authCode": "5c28dac1ff580210e11292df57e87bef"}, "code": "0000", "msg": "X"}')
|
||||
r3 = m.post(re.compile('user.do'),
|
||||
text='{"todo": "result", "token": "jt5O7oDR3gPHdVKCeb8Czx8xw8mDXM6s", "result": "ok", "userId": "2017102559f0ee63c588d", "resource": "f8d99c4d"}')
|
||||
api = EcoVacsAPI("long_device_id", "account_id", "password_hash", 'us', 'na')
|
||||
EcoVacsAPI("long_device_id", "account_id", "password_hash", 'us', 'na')
|
||||
assert_equals(r1.call_count, 1)
|
||||
assert_equals(r2.call_count, 1)
|
||||
assert_equals(r3.call_count, 1)
|
||||
|
||||
Reference in New Issue
Block a user