Exemplo n.º 1
0
    def test_os_info_debian_distro(self):
        expected_output = {
            'distribution': 'ec2',
            'version': '16.04',
            'dist_name': 'Ubuntu',
            'based_on': 'debian'
        }
        mock_response = mock.Mock()
        mock_response.side_effect = [False, True]

        with mock.patch('tests.fixtures.command_returns.sys') as v_info:
            v_info.version_info = (3, 8, 0, 'final', 0)
            with mock.patch('ae_preflight.profile.sys') as version:
                version.version_info = (3, 8, 0, 'final', 0)
                with mock.patch(
                    'ae_preflight.profile.distro.distro_release_info'
                ) as os:
                    os.return_value = command_returns.distro_release_info(
                        'ubuntu'
                    )
                    with mock.patch(
                        'ae_preflight.profile.os.path.isfile',
                        side_effect=mock_response
                    ):
                        os_info = profile.get_os_info(True)

        self.assertEquals(
            expected_output,
            os_info,
            'OS information returned was not the expected value'
        )
Exemplo n.º 2
0
    def test_os_info_suse_platform(self):
        expected_output = {
            'distribution': 'suse',
            'version': '12',
            'dist_name': 'SUSE Linux Enterprise Server',
            'based_on': 'suse'
        }
        mock_response = mock.Mock()
        mock_response.side_effect = [False, False, True]

        with mock.patch('tests.fixtures.command_returns.sys') as v_info:
            v_info.version_info = (3, 7, 0, 'final', 0)
            with mock.patch('ae_preflight.profile.sys') as version:
                version.version_info = (3, 7, 0, 'final', 0)
                with mock.patch(
                    'ae_preflight.profile.platform.linux_distribution'
                ) as os:
                    os.return_value = command_returns.distro_release_info(
                        'suse'
                    )
                    with mock.patch(
                        'ae_preflight.profile.os.path.isfile',
                        side_effect=mock_response
                    ):
                        os_info = profile.get_os_info(True)

        self.assertEquals(
            expected_output,
            os_info,
            'OS information returned was not the expected value'
        )
Exemplo n.º 3
0
    def test_os_info_debian_platform(self):
        expected_output = {
            'distribution': 'ubuntu',
            'version': '16.04',
            'dist_name': 'Ubuntu',
            'based_on': 'debian'
        }
        mock_response = mock.Mock()
        mock_response.side_effect = [False, True]
        lsb_return = ('DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=16.04\n'
                      'DISTRIB_CODENAME=xenial\nDISTRIB_DESCRIPTION="'
                      'Ubuntu 16.04.6 LTS"\n')
        mocked_open = mock.mock_open(read_data=lsb_return)

        with mock.patch('tests.fixtures.command_returns.sys') as v_info:
            v_info.version_info = (3, 7, 0, 'final', 0)
            with mock.patch('ae_preflight.profile.sys') as version:
                version.version_info = (3, 7, 0, 'final', 0)
                with mock.patch(
                        'ae_preflight.profile.platform.linux_distribution'
                ) as os:
                    os.return_value = command_returns.distro_release_info(
                        'ubuntu')
                    with mock.patch('ae_preflight.profile.open', mocked_open):
                        with mock.patch('ae_preflight.profile.os.path.isfile',
                                        side_effect=mock_response):
                            os_info = profile.get_os_info(True)

        self.assertEquals(
            expected_output, os_info,
            'OS information returned was not the expected value')
Exemplo n.º 4
0
    def test_os_info_rhel_distro(self):
        expected_output = {
            'distribution': 'centos',
            'version': '7.5',
            'dist_name': 'CentOS Linux',
            'based_on': 'rhel'
        }
        with mock.patch('tests.fixtures.command_returns.sys') as v_info:
            v_info.version_info = (3, 8, 0, 'final', 0)
            with mock.patch('ae_preflight.profile.sys') as version:
                version.version_info = (3, 8, 0, 'final', 0)
                with mock.patch(
                    'ae_preflight.profile.distro.distro_release_info'
                ) as os:
                    os.return_value = command_returns.distro_release_info(
                        'centos'
                    )
                    with mock.patch(
                        'ae_preflight.profile.os.path.isfile'
                    ) as file:
                        file.return_value = True
                        os_info = profile.get_os_info(True)

        self.assertEquals(
            expected_output,
            os_info,
            'OS information returned was not the expected value'
        )
 def test_os_info_suse_distro(self):
     expected_output = {
         'distribution': 'sles',
         'version': '15',
         'dist_name': 'SLES',
         'based_on': 'suse'
     }
     mock_response = mock.Mock()
     mock_response.side_effect = [False, False, True]
     with mock.patch(
             'ae_preflight.profile.distro.distro_release_info') as os:
         os.return_value = {}
         with mock.patch(
                 'ae_preflight.profile.distro.os_release_info') as distro:
             distro.return_value = (
                 command_returns.distro_release_info('suse'))
             with mock.patch('ae_preflight.profile.os.path.isfile',
                             side_effect=mock_response):
                 os_info = profile.get_os_info(True)
     self.assertEquals(
         expected_output, os_info,
         'OS information returned was not the expected value')