'Test that login is done with password when configured to.'

def test_telnet_login_with_password(self):

    telnet = mock.MagicMock()
    telnet_mock = mock.patch('telnetlib.Telnet', return_value=telnet)
    telnet_mock.start()
    self.addCleanup(telnet_mock.stop)
    conf_dict = PLATFORM_SCHEMA({CONF_PLATFORM: 'asuswrt', CONF_PROTOCOL: 'telnet', CONF_HOST: 'fake_host', CONF_USERNAME: 'fake_user', CONF_PASSWORD: 'fake_pass'})
    update_mock = mock.patch('homeassistant.components.device_tracker.asuswrt.AsusWrtDeviceScanner.get_asuswrt_data')
    update_mock.start()
    self.addCleanup(update_mock.stop)
    asuswrt = device_tracker.asuswrt.AsusWrtDeviceScanner(conf_dict)
    asuswrt.connection.get_result()
    self.assertEqual(telnet.read_until.call_count, 5)
    self.assertEqual(telnet.write.call_count, 4)
    self.assertEqual(telnet.read_until.call_args_list[0], mock.call('login:    '))
    self.assertEqual(telnet.write.call_args_list[0], mock.call('fake_user\n'))
    self.assertEqual(telnet.read_until.call_args_list[1], mock.call('Password:    '))
    self.assertEqual(telnet.write.call_args_list[1], mock.call('fake_pass\n'))
    self.assertEqual(telnet.read_until.call_args_list[2], mock.call('#'))
