Пример #1
0
    def test_make_pkgng_aware(self):
        '''
        Test if it make jail ``jname`` pkgng aware.
        '''
        ret1 = 'Could not create or find required directory /tmp/salt'
        ret2 = 'Looks like file /tmp/salt/salt-make.conf could not be created'
        ret3 = {'changes': 'Created /tmp/salt/salt-make.conf'}
        mock = MagicMock(return_value='/tmp/salt')
        mock_true = MagicMock(return_value=True)
        with patch.dict(poudriere.__salt__, {'config.option': mock,
                                             'file.write': mock_true}):
            with patch.object(os.path, 'isdir', MagicMock(return_value=False)):
                with patch.object(os, 'makedirs', mock_true):
                    self.assertEqual(poudriere.make_pkgng_aware('salt'), ret1)

            with patch.object(os.path, 'isdir', mock_true):
                self.assertEqual(poudriere.make_pkgng_aware('salt'), ret2)

                with patch.object(os.path, 'isfile', mock_true):
                    self.assertDictEqual(poudriere.make_pkgng_aware('salt'),
                                         ret3)
Пример #2
0
    def test_make_pkgng_aware(self):
        '''
        Test if it make jail ``jname`` pkgng aware.
        '''
        temp_dir = os.path.join('tmp', 'salt')
        conf_file = os.path.join('tmp', 'salt', 'salt-make.conf')
        ret1 = 'Could not create or find required directory {0}'.format(temp_dir)
        ret2 = 'Looks like file {0} could not be created'.format(conf_file)
        ret3 = {'changes': 'Created {0}'.format(conf_file)}
        mock = MagicMock(return_value=temp_dir)
        mock_true = MagicMock(return_value=True)
        with patch.dict(poudriere.__salt__, {'config.option': mock,
                                             'file.write': mock_true}):
            with patch.object(os.path, 'isdir', MagicMock(return_value=False)):
                with patch.object(os, 'makedirs', mock_true):
                    self.assertEqual(poudriere.make_pkgng_aware('salt'), ret1)

            with patch.object(os.path, 'isdir', mock_true):
                self.assertEqual(poudriere.make_pkgng_aware('salt'), ret2)

                with patch.object(os.path, 'isfile', mock_true):
                    self.assertDictEqual(poudriere.make_pkgng_aware('salt'),
                                         ret3)
Пример #3
0
    def test_make_pkgng_aware(self):
        '''
        Test if it make jail ``jname`` pkgng aware.
        '''
        ret1 = 'Could not create or find required directory /tmp/salt'
        ret2 = 'Looks like file /tmp/salt/salt-make.conf could not be created'
        ret3 = {'changes': 'Created /tmp/salt/salt-make.conf'}
        mock = MagicMock(return_value='/tmp/salt')
        mock_true = MagicMock(return_value=True)
        with patch.dict(poudriere.__salt__, {
                'config.option': mock,
                'file.write': mock_true
        }):
            with patch.object(os.path, 'isdir', MagicMock(return_value=False)):
                with patch.object(os, 'makedirs', mock_true):
                    self.assertEqual(poudriere.make_pkgng_aware('salt'), ret1)

            with patch.object(os.path, 'isdir', mock_true):
                self.assertEqual(poudriere.make_pkgng_aware('salt'), ret2)

                with patch.object(os.path, 'isfile', mock_true):
                    self.assertDictEqual(poudriere.make_pkgng_aware('salt'),
                                         ret3)
Пример #4
0
def test_make_pkgng_aware():
    """
    Test if it make jail ``jname`` pkgng aware.
    """
    temp_dir = os.path.join("tmp", "salt")
    conf_file = os.path.join("tmp", "salt", "salt-make.conf")
    ret1 = "Could not create or find required directory {}".format(temp_dir)
    ret2 = "Looks like file {} could not be created".format(conf_file)
    ret3 = {"changes": "Created {}".format(conf_file)}
    mock = MagicMock(return_value=temp_dir)
    mock_true = MagicMock(return_value=True)
    with patch.dict(
        poudriere.__salt__, {"config.option": mock, "file.write": mock_true}
    ):
        with patch.object(os.path, "isdir", MagicMock(return_value=False)):
            with patch.object(os, "makedirs", mock_true):
                assert poudriere.make_pkgng_aware("salt") == ret1

        with patch.object(os.path, "isdir", mock_true):
            assert poudriere.make_pkgng_aware("salt") == ret2

            with patch.object(os.path, "isfile", mock_true):
                assert poudriere.make_pkgng_aware("salt") == ret3