Ejemplo n.º 1
0
 def test_remove_nopan_error(self):
     '''
     Test if it gives no cpan error while removing
     '''
     ret = {'error': 'No CPAN data available to use for uninstalling'}
     mock = MagicMock(return_value={'installed version': '2.1'})
     with patch.object(cpan, 'show', mock):
         self.assertDictEqual(cpan.remove('Alloy'), ret)
Ejemplo n.º 2
0
 def test_remove_nopan_error(self):
     '''
     Test if it gives no cpan error while removing
     '''
     ret = {'error': 'No CPAN data available to use for uninstalling'}
     mock = MagicMock(return_value={'installed version': '2.1'})
     with patch.object(cpan, 'show', mock):
         self.assertDictEqual(cpan.remove('Alloy'), ret)
Ejemplo n.º 3
0
 def test_remove_nopan_error(self):
     """
     Test if it gives no cpan error while removing
     """
     ret = {"error": "No CPAN data available to use for uninstalling"}
     mock = MagicMock(return_value={"installed version": "2.1"})
     with patch.object(cpan, "show", mock):
         self.assertDictEqual(cpan.remove("Alloy"), ret)
Ejemplo n.º 4
0
 def test_remove_noninstalled_error(self):
     '''
     Test if it remove non installed module using cpan
     '''
     mock = MagicMock(return_value={'installed version': None})
     with patch.object(cpan, 'show', mock):
         self.assertDictEqual(cpan.remove('Alloy'),
                              {'new': None, 'old': None})
Ejemplo n.º 5
0
 def test_remove_unexist_error(self):
     '''
     Test if it try to remove an unexist module using cpan
     '''
     mock = MagicMock(return_value="don't know what it is")
     with patch.dict(cpan.__salt__, {'cmd.run': mock}):
         self.assertDictEqual(
             cpan.remove('Alloy'),
             {'error': 'This package does not seem to exist'})
Ejemplo n.º 6
0
 def test_remove_unexist_error(self):
     '''
     Test if it try to remove an unexist module using cpan
     '''
     mock = MagicMock(return_value="don't know what it is")
     with patch.dict(cpan.__salt__, {'cmd.run': mock}):
         self.assertDictEqual(cpan.remove('Alloy'),
                              {'error':
                               'This package does not seem to exist'})
Ejemplo n.º 7
0
 def test_remove_unexist_error(self):
     """
     Test if it try to remove an unexist module using cpan
     """
     mock = MagicMock(return_value="don't know what it is")
     with patch.dict(cpan.__salt__, {"cmd.run": mock}):
         self.assertDictEqual(
             cpan.remove("Alloy"),
             {"error": "This package does not seem to exist"})
Ejemplo n.º 8
0
 def test_remove_noninstalled_error(self):
     '''
     Test if it remove non installed module using cpan
     '''
     mock = MagicMock(return_value={'installed version': None})
     with patch.object(cpan, 'show', mock):
         self.assertDictEqual(cpan.remove('Alloy'), {
             'new': None,
             'old': None
         })
Ejemplo n.º 9
0
 def test_remove_noninstalled_error(self):
     """
     Test if it remove non installed module using cpan
     """
     mock = MagicMock(return_value={"installed version": None})
     with patch.object(cpan, "show", mock):
         self.assertDictEqual(cpan.remove("Alloy"), {
             "new": None,
             "old": None
         })
Ejemplo n.º 10
0
 def test_remove_unexist_error(self):
     '''
     Test if it try to remove an unexist module using cpan
     '''
     mock = MagicMock(return_value={'error': ""})
     module = 'Nonexistant::Package'
     with patch.dict(cpan.__salt__, {'cmd.run_all': mock}):
         self.assertDictEqual(cpan.remove(module), {
             'error': 'Could not find package {}'.format(module),
             'new': None,
             'old': None})
Ejemplo n.º 11
0
 def test_remove(self):
     '''
     Test if it remove a module using cpan
     '''
     mock = MagicMock(return_value='')
     with patch.dict(cpan.__salt__, {'cmd.run': mock}):
         mock = MagicMock(return_value={'installed version': '2.1',
                                        'cpan build dirs': [''],
                                        'installed file': '/root'})
         with patch.object(cpan, 'show', mock):
             self.assertDictEqual(cpan.remove('Alloy'),
                                  {'new': None, 'old': '2.1'})
Ejemplo n.º 12
0
 def test_remove_no_cpan_error(self):
     '''
     Test if it gives no cpan error while removing,
     If nothing has changed then an empty dictionary will be returned
     '''
     mock = MagicMock(return_value={'installed version': '2.1',
                                    'installed file': "",
                                    'cpan build dirs': []})
     with patch.object(cpan, 'show', mock):
         self.assertDictEqual(cpan.remove('File::Temp'), {
             'error': None,
             'new': None,
             'old': None})
Ejemplo n.º 13
0
 def test_remove(self):
     '''
     Test if it remove a module using cpan
     '''
     with patch('os.listdir', MagicMock(return_value=[''])):
         mock = MagicMock(return_value={})
         module = 'File::Temp'
         with patch.dict(cpan.__salt__, {'cmd.run_all': mock}):
             mock = MagicMock(return_value={'installed version': '2.1',
                                            'cpan build dirs': [''],
                                            'installed file': '/root'})
             with patch.object(cpan, 'show', mock):
                 self.assertDictEqual(cpan.remove(module), {
                     'error': None,
                     'new': None,
                     'old': None})
Ejemplo n.º 14
0
 def test_remove(self):
     '''
     Test if it remove a module using cpan
     '''
     mock = MagicMock(return_value='')
     with patch.dict(cpan.__salt__, {'cmd.run': mock}):
         mock = MagicMock(
             return_value={
                 'installed version': '2.1',
                 'cpan build dirs': [''],
                 'installed file': '/root'
             })
         with patch.object(cpan, 'show', mock):
             self.assertDictEqual(cpan.remove('Alloy'), {
                 'new': None,
                 'old': '2.1'
             })
Ejemplo n.º 15
0
 def test_remove(self):
     """
     Test if it remove a module using cpan
     """
     with patch("os.listdir", MagicMock(return_value=[""])):
         mock = MagicMock(return_value="")
         with patch.dict(cpan.__salt__, {"cmd.run": mock}):
             mock = MagicMock(
                 return_value={
                     "installed version": "2.1",
                     "cpan build dirs": [""],
                     "installed file": "/root",
                 })
             with patch.object(cpan, "show", mock):
                 self.assertDictEqual(cpan.remove("Alloy"), {
                     "new": None,
                     "old": "2.1"
                 })
Ejemplo n.º 16
0
    def test_remove(self):
        """
        Test if it remove a module using cpan
        '''
        with patch('os.listdir', MagicMock(return_value=[''])):
            mock = MagicMock(return_value={})
            module = 'File::Temp'
            with patch.dict(cpan.__salt__, {'cmd.run_all': mock}):
                mock = MagicMock(return_value={'installed version': '2.1',
                                               'cpan build dirs': [''],
                                               'installed file': '/root'})
                with patch.object(cpan, 'show', mock):
                    self.assertDictEqual(cpan.remove(module), {
                        'error': None,
                        'new': None,
                        'old': None})

    def test_remove_unexist_error(self):
        """
        Test if it try to remove an unexist module using cpan
        '''
        mock = MagicMock(return_value={'error': ""})
        module = 'Nonexistant::Package'
        with patch.dict(cpan.__salt__, {'cmd.run_all': mock}):
            self.assertDictEqual(cpan.remove(module), {
                'error': 'Could not find package {}'.format(module),
                'new': None,
                'old': None})

    def test_remove_noninstalled_error(self):
        """
        Test if it remove non installed module using cpan
        '''
        mock = MagicMock(return_value={'installed version': None})
        with patch.object(cpan, 'show', mock):
            self.assertDictEqual(cpan.remove('File::Temp'), {
                'error': None,
                'new': None,
                'old': None})