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