def initialize(self, host, cfm_test):
        """
        Initializes the test.

        @param host The host the test is run against
        @param cfm_test CfmTest instance to execute.
        """
        (super(ConfigurableCfmTest, self)
            .initialize(host,
                        cfm_test.configuration.run_test_only,
                        cfm_test.configuration.skip_enrollment))
        self.cfm_test = cfm_test
        device_collector = usb_device_collector.UsbDeviceCollector(host)
        port_manager = usb_port_manager.UsbPortManager(host)
        crash_file_detector = crash_detector.CrashDetector(host)
        # Call get_new_crash_files() once. This records the current crash
        # files so that subsequent calls only check the delta, i.e.
        # new crash files from here on.
        crash_file_detector.get_new_crash_files()
        # self.cfm_facade is inherited from CfmBaseTest.
        context = action_context.ActionContext(
                cfm_facade=self.cfm_facade,
                file_contents_collector=HostFileContentsCollector(host),
                host=host,
                usb_device_collector=device_collector,
                usb_port_manager=port_manager,
                crash_detector=crash_file_detector)
        self.test_runner = TestRunner(context)
 def setUp(self):
     self.host_mock = mock.MagicMock()
     self.cfm_facade_mock = mock.MagicMock()
     self.usb_device_collector_mock = mock.MagicMock()
     self.usb_port_manager_mock = mock.MagicMock()
     self.crash_detector_mock = mock.MagicMock()
     self.context_with_mocks = action_context.ActionContext(
         host=self.host_mock,
         cfm_facade=self.cfm_facade_mock,
         usb_device_collector=self.usb_device_collector_mock,
         usb_port_manager=self.usb_port_manager_mock,
         crash_detector=self.crash_detector_mock)
Esempio n. 3
0
 def test_join_leave(self):
     cfm_test = CfmTest(
         scenario=Scenario(
             CreateMeeting(),
             LeaveMeeting()
         )
     )
     cfm_facade_mock = MagicMock(
             spec=cfm_facade_adapter.CFMFacadeRemoteAdapter)
     context = action_context.ActionContext(cfm_facade=cfm_facade_mock)
     runner = configurable_cfm_test.TestRunner(context)
     runner.run_test(cfm_test)
     cfm_facade_mock.start_meeting_session.assert_called_once_with()
     cfm_facade_mock.end_meeting_session.assert_called_once_with()
Esempio n. 4
0
 def test_scenario_with_repeat(self):
     cfm_test = CfmTest(
         scenario=Scenario(
             CreateMeeting(),
             RepeatTimes(5, Scenario(
                 MuteMicrophone(),
             )),
         )
     )
     cfm_facade_mock = MagicMock(
             spec=cfm_facade_adapter.CFMFacadeRemoteAdapter)
     context = action_context.ActionContext(cfm_facade=cfm_facade_mock)
     runner = configurable_cfm_test.TestRunner(context)
     runner.run_test(cfm_test)
     cfm_facade_mock.start_meeting_session.assert_called_once_with()
     self.assertEqual(5, cfm_facade_mock.mute_mic.call_count)
 def test_assert_file_does_not_contain_regex_match(self):
     action = actions.AssertFileDoesNotContain('/foo', ['EE', 'W{3}Q+'])
     context = action_context.ActionContext(
         file_contents_collector=FakeCollector('abc\naWWWQQd'))
     self.assertRaises(AssertionError, lambda: action.execute(context))
 def test_assert_file_does_not_contain_no_match(self):
     action = actions.AssertFileDoesNotContain('/foo', ['EE', 'WW'])
     context = action_context.ActionContext(
         file_contents_collector=FakeCollector('abc\ndef'))
     action.execute(context)