• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import unittest
2from unittest.mock import MagicMock
3
4from autotest_lib.server.cros.cfm.configurable_test import action_context
5from autotest_lib.server.cros.cfm.configurable_test import configurable_cfm_test
6from autotest_lib.server.cros.cfm.configurable_test.dsl import *
7from autotest_lib.server.cros.multimedia import cfm_facade_adapter
8
9# Test, disable missing-docstring
10# Also, disable undefined-variable since the import * confuses the linter (we
11# want to use import * since that is what the control files will use)
12# pylint: disable=missing-docstring,undefined-variable
13class TestConfigurableCfmTest(unittest.TestCase):
14    """Tests running configurable CFM tests."""
15    def test_join_leave(self):
16        cfm_test = CfmTest(
17            scenario=Scenario(
18                CreateMeeting(),
19                LeaveMeeting()
20            )
21        )
22        cfm_facade_mock = MagicMock(
23                spec=cfm_facade_adapter.CFMFacadeRemoteAdapter)
24        context = action_context.ActionContext(cfm_facade=cfm_facade_mock)
25        runner = configurable_cfm_test.TestRunner(context)
26        runner.run_test(cfm_test)
27        cfm_facade_mock.start_meeting_session.assert_called_once_with()
28        cfm_facade_mock.end_meeting_session.assert_called_once_with()
29
30    def test_scenario_with_repeat(self):
31        cfm_test = CfmTest(
32            scenario=Scenario(
33                CreateMeeting(),
34                RepeatTimes(5, Scenario(
35                    MuteMicrophone(),
36                )),
37            )
38        )
39        cfm_facade_mock = MagicMock(
40                spec=cfm_facade_adapter.CFMFacadeRemoteAdapter)
41        context = action_context.ActionContext(cfm_facade=cfm_facade_mock)
42        runner = configurable_cfm_test.TestRunner(context)
43        runner.run_test(cfm_test)
44        cfm_facade_mock.start_meeting_session.assert_called_once_with()
45        self.assertEqual(5, cfm_facade_mock.mute_mic.call_count)
46