blob: 7cc2fff70e67d41c589c39d18d9c266132489583 [file] [log] [blame]
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
from autotest_lib.client.bin import test
from autotest_lib.client.common_lib import error
from autotest_lib.client.cros import shill_temporary_profile
from autotest_lib.client.cros.networking import wifi_proxy
class network_BasicProfileProperties(test.test):
"""Test that shill's DBus properties for profiles work."""
version = 1
def get_field_from_properties(properties, field):
"""Get a field from a dictionary of properties.
Raises an exception on failure.
@param properties dict of properties (presumably from some
DBus object).
@param field string key to search for in |properties|.
@return value of properties[field].
if not field in properties:
raise error.TestFail('No %s field in properties %r?' %
(field, properties))
return properties[field]
def run_once(self):
"""Test body."""
shill = wifi_proxy.WifiProxy.get_proxy()
with shill_temporary_profile.ShillTemporaryProfile(
shill.manager, profile_name=self.PROFILE_NAME):
profiles = shill.get_profiles()'Got profiles %r', profiles)
# The last profile should be the one we just created.
profile = profiles[-1]
profile_properties = shill.dbus2primitive(
logging.debug('Profile properties: %r.', profile_properties)
profile_name = self.get_field_from_properties(
profile_properties, self.PROFILE_PROPERTY_NAME)
if profile_name != self.PROFILE_NAME:
raise error.TestFail('Found unexpected top profile with name '
'%r.' % profile_name)
entries = shill.dbus2primitive(self.get_field_from_properties(
profile_properties, self.PROFILE_PROPERTY_ENTRIES))'Found entries: %r', entries)
ethernet_entry_key = 'ethernet_any'
if not ethernet_entry_key in entries:
raise error.TestFail('Missing ethernet entry %s from profile.' %
entry = profile.GetEntry(ethernet_entry_key)