Пример #1
0
    def test_ntp_disabled(self):
        expected_output = {
            'using': None,
            'installed': 'ntpd',
            'enabled': False,
            'synched': False
        }
        mock_response = mock.Mock()
        mock_response.side_effect = [
            b'/bin/ntpstat',
            command_returns.systemd_not_running_status(),
            b'',
            command_returns.timedatectl_status(synched=False)
        ]
        with mock.patch(
            'ae_preflight.profile.execute_command',
            side_effect=mock_response
        ):
            returns = profile.check_for_ntp_synch(True)

        self.assertEquals(
            expected_output,
            returns,
            'Returned values did not match expected output'
        )
Пример #2
0
    def test_chronyd_enabled(self):
        expected_output = {
            'using': 'chronyd',
            'installed': True,
            'enabled': True,
            'synched': True
        }
        mock_response = mock.Mock()
        mock_response.side_effect = [
            b'',
            b'/sbin/chronyc',
            command_returns.systemd_ntp_chronyd_status('chronyd'),
            command_returns.timedatectl_status(synched=True)
        ]
        with mock.patch(
            'ae_preflight.profile.execute_command',
            side_effect=mock_response
        ):
            returns = profile.check_for_ntp_synch(True)

        self.assertEquals(
            expected_output,
            returns,
            'Returned values did not match expected output'
        )