Exemplo n.º 1
0
    def test_atrm(self):
        """
        Tests for remove jobs from the queue.
        """
        with patch("salt.modules.at.atq", MagicMock(return_value=self.atq_output)):
            with patch.object(salt.utils.path, "which", return_value=None):
                self.assertEqual(at.atrm(), "'at.atrm' is not available.")

            with patch.object(salt.utils.path, "which", return_value=True):
                self.assertDictEqual(at.atrm(), {"jobs": {"removed": [], "tag": None}})

            with patch.object(at, "_cmd", return_value=True):
                with patch.object(salt.utils.path, "which", return_value=True):
                    self.assertDictEqual(
                        at.atrm("all"), {"jobs": {"removed": ["101"], "tag": None}}
                    )

            with patch.object(at, "_cmd", return_value=True):
                with patch.object(salt.utils.path, "which", return_value=True):
                    self.assertDictEqual(
                        at.atrm(101), {"jobs": {"removed": ["101"], "tag": None}}
                    )

            with patch.object(at, "_cmd", return_value=None):
                self.assertEqual(at.atrm(101), "'at.atrm' is not available.")
Exemplo n.º 2
0
    def test_atrm(self):
        """
        Tests for remove jobs from the queue.
        """
        with patch.object(salt.utils, 'which', return_value=None):
            self.assertEqual(at.atrm(), "'at.atrm' is not available.")

        with patch.object(salt.utils, 'which', return_value=True):
            self.assertDictEqual(at.atrm(), {'jobs': {'removed': [],
                                                      'tag': None}})

        with patch.object(at, '_cmd', return_value=True):
            with patch.object(salt.utils, 'which', return_value=True):
                self.assertDictEqual(at.atrm('all'),
                                     {'jobs': {'removed': ['101'],
                                               'tag': None}})

        with patch.object(at, '_cmd', return_value=True):
            with patch.object(salt.utils, 'which', return_value=True):
                self.assertDictEqual(at.atrm(101),
                                     {'jobs': {'removed': ['101'],
                                               'tag': None}})

        with patch.object(at, '_cmd', return_value=None):
            self.assertEqual(at.atrm(101), '\'at.atrm\' is not available.')
Exemplo n.º 3
0
    def test_atrm(self):
        """
        Tests for remove jobs from the queue.
        """
        with patch('salt.modules.at.atq', MagicMock(return_value=self.atq_output)):
            with patch.object(salt.utils, 'which', return_value=None):
                self.assertEqual(at.atrm(), "'at.atrm' is not available.")

            with patch.object(salt.utils, 'which', return_value=True):
                self.assertDictEqual(at.atrm(), {'jobs': {'removed': [],
                                                          'tag': None}})

            with patch.object(at, '_cmd', return_value=True):
                with patch.object(salt.utils, 'which', return_value=True):
                    self.assertDictEqual(at.atrm('all'),
                                         {'jobs': {'removed': ['101'],
                                                   'tag': None}})

            with patch.object(at, '_cmd', return_value=True):
                with patch.object(salt.utils, 'which', return_value=True):
                    self.assertDictEqual(at.atrm(101),
                                         {'jobs': {'removed': ['101'],
                                                   'tag': None}})

            with patch.object(at, '_cmd', return_value=None):
                self.assertEqual(at.atrm(101), '\'at.atrm\' is not available.')