Beispiel #1
0
    def test_range(self):
        events = devcron.parse_crontab('1-10 * * * * cmd')
        self.assertEqual(events[0].mins, set(range(1, 11)))

        events = devcron.parse_crontab('1-10,12 * * * * cmd')
        self.assertEqual(events[0].mins, set(range(1, 11)).union({12}))

        events = devcron.parse_crontab('1-10,12-20 * * * * cmd')
        self.assertEqual(events[0].mins, set(range(1, 11)).union(set(range(12, 21))))
Beispiel #2
0
    def test_range(self):
        events = devcron.parse_crontab('1-10 * * * * cmd')
        self.assertEqual(events[0].mins, set(range(1, 11)))

        events = devcron.parse_crontab('1-10,12 * * * * cmd')
        self.assertEqual(events[0].mins, set(range(1, 11)).union({12}))

        events = devcron.parse_crontab('1-10,12-20 * * * * cmd')
        self.assertEqual(events[0].mins,
                         set(range(1, 11)).union(set(range(12, 21))))
Beispiel #3
0
    def test_bad_format(self):
        bad_inputs = [
            '1',
            '1 2 3 cmd',
            'one 2 3 4 5 cmd',
            '1 2 3 4 *5 cmd',
        ]

        for input in bad_inputs:
            with self.assertRaises(NotImplementedError):
                devcron.parse_crontab(input)
Beispiel #4
0
    def test_bad_format(self):
        bad_inputs = [
            '1',
            '1 2 3 cmd',
            'one 2 3 4 5 cmd',
            '1 2 3 4 *5 cmd',
        ]

        for input in bad_inputs:
            with self.assertRaises(NotImplementedError):
                devcron.parse_crontab(input)
Beispiel #5
0
 def test_weekly(self):
     events = devcron.parse_crontab('@weekly cmd')
     self.assertEqual(len(events), 1)
     e = events[0]
     self.assertEqual((e.mins, e.hours, e.dow), ({0}, {0}, {0}))
     self.assertIsInstance(e.days, devcron.DivisableMatch)
     self.assertIsInstance(e.months, devcron.DivisableMatch)
Beispiel #6
0
 def test_weekly(self):
     events = devcron.parse_crontab('@weekly cmd')
     self.assertEqual(len(events), 1)
     e = events[0]
     self.assertEqual((e.mins, e.hours, e.dow), ({0}, {0}, {0}))
     self.assertIsInstance(e.days, devcron.DivisableMatch)
     self.assertIsInstance(e.months, devcron.DivisableMatch)
Beispiel #7
0
 def test_parse_simple(self):
     cnt = 5
     events = devcron.parse_crontab('1 2 3 4 5 cmd\n' * cnt)
     self.assertEqual(len(events), cnt)
     for e in events:
         self.assertEqual(
             (e.mins, e.hours, e.days, e.months, e.dow, e.args, e.kwargs),
             ({1}, {2}, {3}, {4}, {5}, tuple(), dict()))
Beispiel #8
0
 def test_parse_simple(self):
     cnt = 5
     events = devcron.parse_crontab('1 2 3 4 5 cmd\n' * cnt)
     self.assertEqual(len(events), cnt)
     for e in events:
         self.assertEqual(
             (e.mins, e.hours, e.days, e.months, e.dow, e.args, e.kwargs),
             ({1}, {2}, {3}, {4}, {5}, tuple(), dict())
         )
Beispiel #9
0
 def test_unknown_freq(self):
     with self.assertRaises(NotImplementedError):
         devcron.parse_crontab('@daily cmd')
Beispiel #10
0
 def test_whitespace(self):
     events = devcron.parse_crontab(
         '     \n\n   1   2   3   4   5   cmd    \n\n\n')
     self.assertEqual(len(events), 1)
Beispiel #11
0
 def test_parse_asterisk_divisor(self):
     events = devcron.parse_crontab('*/10 * * * * cmd')
     self.assertEqual(len(events), 1)
     self.assertIsInstance(events[0].mins, devcron.DivisableMatch)
     self.assertEqual(events[0].mins.divisor, 10)
Beispiel #12
0
    def test_range_with_divisor(self):
        events = devcron.parse_crontab('1-59/2 * * * * cmd')
        self.assertEqual(events[0].mins, set(range(1, 60, 2)))

        events = devcron.parse_crontab('1,2,3,5,8,13,21/3 * * * * cmd')
        self.assertEqual(events[0].mins, {1, 5, 21})
Beispiel #13
0
 def test_parse_comments(self):
     events = devcron.parse_crontab(
         '* * * * * cmd\n#comment\n1 2 3 4 5 cmd')
     self.assertEqual(len(events), 2)
Beispiel #14
0
 def test_parse_asterisk_divisor(self):
     events = devcron.parse_crontab('*/10 * * * * cmd')
     self.assertEqual(len(events), 1)
     self.assertIsInstance(events[0].mins, devcron.DivisableMatch)
     self.assertEqual(events[0].mins.divisor, 10)
Beispiel #15
0
    def test_range_with_divisor(self):
        events = devcron.parse_crontab('1-59/2 * * * * cmd')
        self.assertEqual(events[0].mins, set(range(1, 60, 2)))

        events = devcron.parse_crontab('1,2,3,5,8,13,21/3 * * * * cmd')
        self.assertEqual(events[0].mins, {1, 5, 21})
Beispiel #16
0
 def test_parse_asterisk(self):
     events = devcron.parse_crontab('* * * * * cmd')
     self.assertEqual(len(events), 1)
     e = events[0]
     for x in (e.mins, e.hours, e.days, e.months, e.dow):
         self.assertIsInstance(x, devcron.DivisableMatch)
Beispiel #17
0
 def test_parse_asterisk(self):
     events = devcron.parse_crontab('* * * * * cmd')
     self.assertEqual(len(events), 1)
     e = events[0]
     for x in (e.mins, e.hours, e.days, e.months, e.dow):
         self.assertIsInstance(x, devcron.DivisableMatch)
Beispiel #18
0
 def test_parse_comments(self):
     events = devcron.parse_crontab('* * * * * cmd\n#comment\n1 2 3 4 5 cmd')
     self.assertEqual(len(events), 2)
Beispiel #19
0
 def test_unknown_freq(self):
     with self.assertRaises(NotImplementedError):
         devcron.parse_crontab('@daily cmd')
Beispiel #20
0
 def test_whitespace(self):
     events = devcron.parse_crontab('     \n\n   1   2   3   4   5   cmd    \n\n\n')
     self.assertEqual(len(events), 1)