Example #1
0
 def test_show_mock(self):
     '''
     Test if it show information about a specific Perl module
     '''
     mock = MagicMock(return_value='Salt module installed')
     with patch.dict(cpan.__salt__, {'cmd.run': mock}):
         self.assertDictEqual(cpan.show('Alloy'), {'Salt': 'salt'})
Example #2
0
 def test_show_mock(self):
     '''
     Test if it show information about a specific Perl module
     '''
     mock = MagicMock(return_value='Salt module installed')
     with patch.dict(cpan.__salt__, {'cmd.run': mock}):
         self.assertDictEqual(cpan.show('Alloy'), {'Salt': 'salt'})
Example #3
0
    def test_list(self):
        """
        Test if it list installed Perl module
        '''
        mock = MagicMock(return_value={})
        with patch.object(salt.utils.path, 'which', MagicMock(return_value='/usr/bin/cpan')):
            with patch.dict(cpan.__salt__, {'cmd.run_all': mock}):
                self.assertDictEqual(cpan.list_(), {})

    # 'show' function tests: 2
    def test_show(self):
        """
        Test if it show information about a specific Perl module
        '''
        mock = MagicMock(return_value={})
        with patch.dict(cpan.__salt__,
                        {'cmd.run_all': mock,
                         'cpan._grt_bin_env': 'cpan'}):
            module = 'Nonexistant::Package'
            self.assertDictEqual(cpan.show(module),
                                 {'error':
                                      'Could not find package {}'.format(
                                          module),
                                  'name': module})

    def test_show_mock(self):
        """
        Test if it show information about a specific Perl module
        '''
        with patch('salt.modules.cpan.show',
                   MagicMock(return_value={'Salt': 'salt'})):
            mock = MagicMock(return_value='Salt module installed')
            with patch.dict(cpan.__salt__, {'cmd.run_all': mock}):
                self.assertDictEqual(cpan.show('File::Temp'),
                                     {'Salt': 'salt'})
Example #4
0
 def test_show_mock(self):
     """
     Test if it show information about a specific Perl module
     """
     with patch("salt.modules.cpan.show",
                MagicMock(return_value={"Salt": "salt"})):
         mock = MagicMock(return_value="Salt module installed")
         with patch.dict(cpan.__salt__, {"cmd.run": mock}):
             self.assertDictEqual(cpan.show("Alloy"), {"Salt": "salt"})
Example #5
0
 def test_show(self):
     '''
     Test if it show information about a specific Perl module
     '''
     mock = MagicMock(return_value='')
     with patch.dict(cpan.__salt__, {'cmd.run': mock}):
         self.assertDictEqual(cpan.show('Alloy'), {
             'error': 'This package does not seem to exist',
             'name': 'Alloy'
         })
Example #6
0
 def test_show(self):
     '''
     Test if it show information about a specific Perl module
     '''
     mock = MagicMock(return_value='')
     with patch.dict(cpan.__salt__, {'cmd.run': mock}):
         self.assertDictEqual(cpan.show('Alloy'),
                              {'error':
                               'This package does not seem to exist',
                               'name': 'Alloy'})
Example #7
0
 def test_show_mock(self):
     '''
     Test if it show information about a specific Perl module
     '''
     with patch('salt.modules.cpan.show',
                MagicMock(return_value={'Salt': 'salt'})):
         mock = MagicMock(return_value='Salt module installed')
         with patch.dict(cpan.__salt__, {'cmd.run_all': mock}):
             self.assertDictEqual(cpan.show('File::Temp'),
                                  {'Salt': 'salt'})
Example #8
0
 def test_show(self):
     """
     Test if it show information about a specific Perl module
     """
     mock = MagicMock(return_value="")
     with patch.dict(cpan.__salt__, {"cmd.run": mock}):
         self.assertDictEqual(
             cpan.show("Alloy"),
             {
                 "error": "This package does not seem to exist",
                 "name": "Alloy"
             },
         )
Example #9
0
 def test_show(self):
     '''
     Test if it show information about a specific Perl module
     '''
     mock = MagicMock(return_value={})
     with patch.dict(cpan.__salt__,
                     {'cmd.run_all': mock,
                      'cpan._grt_bin_env': 'cpan'}):
         module = 'Nonexistant::Package'
         self.assertDictEqual(cpan.show(module),
                              {'error':
                                   'Could not find package {}'.format(
                                       module),
                               'name': module})