コード例 #1
0
 def _test_100_disable(self):
     """Test case for disable()"""
     try:
         self.device.ethernet_switch_api.disable()
         asserts.assert_false(self.device.ethernet_switch_api.status,
                              "status should be False")
     except Exception:
         traceback_message = traceback.format_exc()
         asserts.fail("Error happened during unlock: " + traceback_message)
コード例 #2
0
 def _verify_no_unexpected_reboots(self, start_time):
     """Verify no unexpected reboots after start time."""
     bootups = self.device.event_parser.get_unexpected_reboots()
     unexpected_timestamps = [
         event["system_timestamp"] for event in bootups
         if event["system_timestamp"] > start_time
     ]
     asserts.assert_false(
         unexpected_timestamps,
         "There were {} unexpected bootups after {} at {}".format(
             len(unexpected_timestamps), start_time, unexpected_timestamps))
コード例 #3
0
    def test_1117_get_event_related_methods_return_appropriate_results(self):
        """Verify Parser accepts valid event label for get_last_event* methods.
        """

        event_data = self.device.event_parser.get_last_event(
            ["optional_description.my_message"])
        asserts.assert_false(
            event_data.results_list,
            "Expecting empty list for 'optional_description.my_message' "
            "event label but found {!r} instead.".format(event_data))

        event_data = self.device.event_parser.get_last_event()
        asserts.assert_false(event_data.timedout,
                             "Expecting EventResult with .timedout == False")

        event_history = self.device.event_parser.get_event_history(
            ["optional_description.my_message"])
        asserts.assert_false(
            event_history.results_list, "Expecting empty list for history of "
            "'optional_description.my_message' event label "
            "but found {!r} instead.".format(event_history))

        event_history = self.device.event_parser.get_event_history(count=1)
        asserts.assert_false(event_data.timedout,
                             "Expecting EventResult with .timedout == False")

        event_history_count = self.device.event_parser.get_event_history_count(
            "optional_description.my_message")
        asserts.assert_true(
            event_history_count.count == 0,
            "Expecting event history count of 0 for "
            "'optional_description.my_message' event label "
            "but found {} instead.".format(event_history_count))
コード例 #4
0
ファイル: expects.py プロジェクト: yxususe/mobly
def expect_false(condition, msg, extras=None):
    """Expects an expression evaluates to False.

    If the expectation is not met, the test is marked as fail after its
    execution finishes.

    Args:
        expr: The expression that is evaluated.
        msg: A string explaining the details in case of failure.
        extras: An optional field for extra information to be included in test
            result.
    """
    try:
        asserts.assert_false(condition, msg, extras)
    except signals.TestSignal as e:
        logging.exception('Expected a `False` value, got `True`.')
        recorder.add_error(e)
コード例 #5
0
    def test_02_install_and_uninstalled_package(self):
        """Verify the capability to install and uninstall a package."""

        # Install the package and check if it is in the package list.
        self.logger.info('Installing package {} from {}'.format(
            self._package_name, self._package_path))
        self.device.package_management.install_package(self._package_path)
        packages_on_device = self.device.package_management.list_packages()
        asserts.assert_true(
            self._package_name in packages_on_device,
            'New installed package {} should be in the package list.'.format(
                self._package_name))

        # Uninstall the package and check if it is not in the package list.
        self.logger.info('Uninstalling package {}'.format(self._package_name))
        self.device.package_management.uninstall_package(self._package_name)
        packages_on_device = self.device.package_management.list_packages()
        asserts.assert_false(
            self._package_name in packages_on_device,
            'Package {} should be uninstalled and not  in the package list.'.
            format(self._package_name))
コード例 #6
0
ファイル: asserts_test.py プロジェクト: zhisays/mobly
 def test_assert_false(self):
     asserts.assert_false(False, MSG_EXPECTED_EXCEPTION)
     with self.assertRaisesRegex(signals.TestFailure,
                                  MSG_EXPECTED_EXCEPTION):
         asserts.assert_false(True, MSG_EXPECTED_EXCEPTION)
コード例 #7
0
    def test_2003_redetect(self):
        """Executes the code in the device class that supports device detection."""
        self.device.close()
        time.sleep(.2)
        new_file_devices_name = os.path.join(self.log_path,
                                             "test_2003_devices.json")
        new_file_options_name = os.path.join(self.log_path,
                                             "test_2003_device_options.json")

        shutil.copy(self.manager.device_file_name, new_file_devices_name)
        shutil.copy(self.manager.device_options_file_name,
                    new_file_options_name)
        # self.manager._devices
        new_manager = gazoo_device.Manager(
            device_file_name=new_file_devices_name,
            device_options_file_name=new_file_options_name,
            log_directory=self.log_path,
            gdm_log_file=os.path.join(self.log_path, "test_2003_gdm.txt"))
        new_manager.redetect(self.device.name, self.log_path)
        new_manager.close()
        asserts.assert_true(
            (self.device.name in new_manager._devices
             or self.device.name in new_manager.other_devices),
            "Device was not successfully detected. "
            "See test_2003_gdm.txt and {}_detect.txt for more info".format(
                self.device.device_type))
        if self.device.name in new_manager._devices:
            old_dict = self.manager._devices[self.device.name]["persistent"]
            new_dict = new_manager._devices[self.device.name]["persistent"]
        else:
            old_dict = self.manager.other_devices[
                self.device.name]["persistent"]
            new_dict = new_manager.other_devices[
                self.device.name]["persistent"]
        for name, a_dict in [("Old", old_dict), ("Detected", new_dict)]:
            self.logger.info("{} configuration: ".format(name))
            for key, value in a_dict.items():
                self.logger.info("\t{}:{}".format(key, value))

        missing_props = []
        bad_values = []

        for prop, old_value in old_dict.items():
            if prop in new_dict:
                new_value = new_dict[prop]
                if old_value != new_value:
                    bad_values.append("{}: {!r} was previously {!r}".format(
                        prop, new_value, old_value))

            elif prop not in DEPRECATED_PROPERTIES:
                missing_props.append(prop)
        msg = ""
        if missing_props:
            msg += "{} is missing the following previous props: {}.\n".format(
                self.device.name, missing_props)
        if bad_values:
            msg += "{} has the following mismatched values: {}.".format(
                self.device.name, ", ".join(bad_values))

        self.logger.info(msg)
        asserts.assert_false(missing_props or bad_values, msg)
コード例 #8
0
ファイル: truth.py プロジェクト: Blaze-AOSP/system_bt
 def isFalse(self):
     assert_false(self._value, "")