Beispiel #1
0
    def test_atq_list(self):
        '''
        Tests the list all queued and running jobs.
        '''
        with patch('salt.modules.at._cmd') as salt_modules_at__cmd_mock:
            salt_modules_at__cmd_mock.return_value = '101\tThu Dec 11 \
            19:48:47 2014 A B'
            with patch.dict(at.__grains__, {'os_family': '', 'os': ''}):
                self.assertDictEqual(at.atq(), {'jobs': [{'date': '2014-12-11',
                                                          'job': 101,
                                                          'queue': 'A',
                                                          'tag': '',
                                                          'time': '19:48:00',
                                                          'user': '******'}]})

            salt_modules_at__cmd_mock.return_value = '101\t2014-12-11 \
            19:48:47 A B'
            with patch.dict(at.__grains__, {'os_family': 'RedHat', 'os': ''}):
                self.assertDictEqual(at.atq(), {'jobs': [{'date': '2014-12-11',
                                                          'job': 101,
                                                          'queue': 'A',
                                                          'tag': '',
                                                          'time': '19:48:47',
                                                          'user': '******'}]})

            salt_modules_at__cmd_mock.return_value = 'SALT: Dec 11, \
            2014 19:48 A 101 B'
            with patch.dict(at.__grains__, {'os_family': '', 'os': 'OpenBSD'}):
                self.assertDictEqual(at.atq(), {'jobs': [{'date': '2014-12-11',
                                                          'job': '101',
                                                          'queue': 'B',
                                                          'tag': '',
                                                          'time': '19:48:00',
                                                          'user': '******'}]})
Beispiel #2
0
    def test_atq_list(self, salt_modules_at__cmd_mock):
        '''
        Tests the list all queued and running jobs.
        '''
        salt_modules_at__cmd_mock.return_value = '101\tThu Dec 11 \
        19:48:47 2014 A B'
        with patch.dict(at.__grains__, {'os_family': '', 'os': ''}):
            self.assertDictEqual(at.atq(), {'jobs': [{'date': '2014-12-11',
                                                      'job': 101,
                                                      'queue': 'A',
                                                      'tag': '',
                                                      'time': '19:48:00',
                                                      'user': '******'}]})

        salt_modules_at__cmd_mock.return_value = '101\t2014-12-11 \
        19:48:47 A B'
        with patch.dict(at.__grains__, {'os_family': 'RedHat', 'os': ''}):
            self.assertDictEqual(at.atq(), {'jobs': [{'date': '2014-12-11',
                                                      'job': 101,
                                                      'queue': 'A',
                                                      'tag': '',
                                                      'time': '19:48:47',
                                                      'user': '******'}]})

        salt_modules_at__cmd_mock.return_value = 'SALT: Dec 11, \
        2014 19:48 A 101 B'
        with patch.dict(at.__grains__, {'os_family': '', 'os': 'OpenBSD'}):
            self.assertDictEqual(at.atq(), {'jobs': [{'date': '2014-12-11',
                                                      'job': '101',
                                                      'queue': 'B',
                                                      'tag': '',
                                                      'time': '19:48:00',
                                                      'user': '******'}]})
Beispiel #3
0
    def test_atq_list(self):
        """
        Tests the list all queued and running jobs.
        """
        with patch("salt.modules.at._cmd") as salt_modules_at__cmd_mock:
            salt_modules_at__cmd_mock.return_value = "101\tThu Dec 11 \
            19:48:47 2014 A B"

            with patch.dict(at.__grains__, {"os_family": "", "os": ""}):
                self.assertDictEqual(
                    at.atq(),
                    {
                        "jobs": [{
                            "date": "2014-12-11",
                            "job": 101,
                            "queue": "A",
                            "tag": "",
                            "time": "19:48:00",
                            "user": "******",
                        }]
                    },
                )

            salt_modules_at__cmd_mock.return_value = "101\t2014-12-11 \
            19:48:47 A B"

            with patch.dict(at.__grains__, {"os_family": "RedHat", "os": ""}):
                self.assertDictEqual(
                    at.atq(),
                    {
                        "jobs": [{
                            "date": "2014-12-11",
                            "job": 101,
                            "queue": "A",
                            "tag": "",
                            "time": "19:48:47",
                            "user": "******",
                        }]
                    },
                )

            salt_modules_at__cmd_mock.return_value = "SALT: Dec 11, \
            2014 19:48 A 101 B"

            with patch.dict(at.__grains__, {"os_family": "", "os": "OpenBSD"}):
                self.assertDictEqual(
                    at.atq(),
                    {
                        "jobs": [{
                            "date": "2014-12-11",
                            "job": "101",
                            "queue": "B",
                            "tag": "",
                            "time": "19:48:00",
                            "user": "******",
                        }]
                    },
                )
Beispiel #4
0
    def test_atq_no_jobs_available(self):
        '''
        Tests the no jobs available for any type of os_family.
        '''
        with patch.dict(at.__grains__, {'os_family': 'RedHat'}):
            self.assertDictEqual(at.atq(), {'jobs': []})

        with patch.dict(at.__grains__, {'os_family': ''}):
            self.assertDictEqual(at.atq(), {'jobs': []})
Beispiel #5
0
    def test_atq_not_available(self):
        '''
        Tests the at.atq not available for any type of os_family.
        '''
        with patch.dict(at.__grains__, {'os_family': 'RedHat'}):
            self.assertEqual(at.atq(), '\'at.atq\' is not available.')

        with patch.dict(at.__grains__, {'os_family': ''}):
            self.assertEqual(at.atq(), '\'at.atq\' is not available.')
Beispiel #6
0
    def test_atq_no_jobs_available(self):
        '''
        Tests the no jobs available for any type of os_family.
        '''
        with patch.dict(at.__grains__, {'os_family': 'RedHat'}):
            self.assertDictEqual(at.atq(), {'jobs': []})

        with patch.dict(at.__grains__, {'os_family': ''}):
            self.assertDictEqual(at.atq(), {'jobs': []})
Beispiel #7
0
    def test_atq_not_available(self):
        '''
        Tests the at.atq not available for any type of os_family.
        '''
        with patch.dict(at.__grains__, {'os_family': 'RedHat'}):
            self.assertEqual(at.atq(), '\'at.atq\' is not available.')

        with patch.dict(at.__grains__, {'os_family': ''}):
            self.assertEqual(at.atq(), '\'at.atq\' is not available.')
Beispiel #8
0
    def test_atq_no_jobs_available(self):
        """
        Tests the no jobs available for any type of os_family.
        """
        with patch("salt.modules.at._cmd", MagicMock(return_value="")):
            with patch.dict(at.__grains__, {"os_family": "RedHat"}):
                self.assertDictEqual(at.atq(), {"jobs": []})

            with patch.dict(at.__grains__, {"os_family": ""}):
                self.assertDictEqual(at.atq(), {"jobs": []})
Beispiel #9
0
    def test_atq_not_available(self):
        """
        Tests the at.atq not available for any type of os_family.
        """
        with patch("salt.modules.at._cmd", MagicMock(return_value=None)):
            with patch.dict(at.__grains__, {"os_family": "RedHat"}):
                self.assertEqual(at.atq(), "'at.atq' is not available.")

            with patch.dict(at.__grains__, {"os_family": ""}):
                self.assertEqual(at.atq(), "'at.atq' is not available.")
Beispiel #10
0
    def test_atq_no_jobs_available(self):
        '''
        Tests the no jobs available for any type of os_family.
        '''
        with patch('salt.modules.at._cmd', MagicMock(return_value='')):
            with patch.dict(at.__grains__, {'os_family': 'RedHat'}):
                self.assertDictEqual(at.atq(), {'jobs': []})

            with patch.dict(at.__grains__, {'os_family': ''}):
                self.assertDictEqual(at.atq(), {'jobs': []})
Beispiel #11
0
    def test_atq_not_available(self):
        '''
        Tests the at.atq not available for any type of os_family.
        '''
        with patch('salt.modules.at._cmd', MagicMock(return_value=None)):
            with patch.dict(at.__grains__, {'os_family': 'RedHat'}):
                self.assertEqual(at.atq(), '\'at.atq\' is not available.')

            with patch.dict(at.__grains__, {'os_family': ''}):
                self.assertEqual(at.atq(), '\'at.atq\' is not available.')