Exemplo n.º 1
0
    def test_install(self, mock_commands):
        """Verify 'install' is the default command."""
        plugin.main([])

        assert [
            call.install(root=None, clean=False, force=False),
            call.install().__bool__(),  # command status check
        ] == mock_commands.mock_calls
Exemplo n.º 2
0
    def test_install(self, mock_commands):
        """Verify 'install' is the default command."""
        mock_commands.install.__name__ = 'mock'

        plugin.main([])

        assert [
            call.install(root=None, depth=None,
                         clean=False, fetch=True, force=False),
            call.install().__bool__(),  # command status check
        ] == mock_commands.mock_calls
Exemplo n.º 3
0
    def test_install_failure(self):
        """Install attempt fails for whatever reason

        When an install fails, the installation will raise a MsmException.  The
        skill install will be saved to the device skill state as failed and
        the error that caused the exception will be included in the state.
        """
        skill_to_install = self.skill_entry_mock()
        skill_to_install.name = 'skill-test'
        skill_to_install.skill_gid = 'skill-test|99.99'
        skill_to_install.is_beta = False
        skill_to_install.install = Mock(side_effect=MsmException('RED ALERT!'))
        with patch('msm.mycroft_skills_manager.isinstance') as isinstance_mock:
            isinstance_mock.return_value = True
            self.msm.install(skill_to_install, origin='cli')

        with open(self.skills_json_path) as skills_json:
            device_skill_state = json.load(skills_json)

        skill_test_state = dict(name='skill-test',
                                origin='cli',
                                beta=False,
                                status='error',
                                installed=0,
                                updated=0,
                                installation='failed',
                                skill_gid='skill-test|99.99',
                                failure_message='RED ALERT!')
        self.assertIn(skill_test_state, self.msm.device_skill_state['skills'])
        self.assertIn(skill_test_state, device_skill_state['skills'])
        self.assertListEqual([call.install(None)],
                             skill_to_install.method_calls)
Exemplo n.º 4
0
    def test_install(self):
        """Install a skill

        Test that the install method was called on the skill being installed
        and that the new skill was added to the device's skill state.
        """
        skill_to_install = self.skill_entry_mock()
        skill_to_install.name = 'skill-test'
        skill_to_install.skill_gid = 'test-skill|99.99'
        skill_to_install.is_beta = False
        with patch('msm.mycroft_skills_manager.isinstance') as isinstance_mock:
            isinstance_mock.return_value = True
            with patch('msm.mycroft_skills_manager.time') as time_mock:
                time_mock.time.return_value = 100
                self.msm.install(skill_to_install, origin='voice')

        with open(self.skills_json_path) as skills_json:
            device_skill_state = json.load(skills_json)

        skill_test_state = dict(name='skill-test',
                                origin='voice',
                                beta=False,
                                status='active',
                                installed=100,
                                updated=0,
                                installation='installed',
                                skill_gid='test-skill|99.99')
        self.assertIn(skill_test_state, device_skill_state['skills'])
        self.assertListEqual([call.install(None)],
                             skill_to_install.method_calls)
Exemplo n.º 5
0
    def test_lang_not_found(self, gettext, logger):
        # Prepare test
        gettext.translation.side_effect = [FileNotFoundError, gettext]

        # Run test
        i18n.setup()

        # Evaluate test
        calls = [
            call('hanggame.i18n'),
            call().warning('no language set, falling back to default: en_US')
        ]
        logger.getLogger.assert_has_calls(calls)
        calls = [
            call.translation('hanggame', localedir=i18n.LOCALES_DIR),
            call.translation('hanggame', localedir=i18n.LOCALES_DIR,
                             languages=['en_US']),
            call.install()
        ]
        gettext.assert_has_calls(calls)