Commit 456f8b17 authored by Martin Owens's avatar Martin Owens 🕘
Browse files

Repair user testing

parent bea7d6a7
Loading
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -32,14 +32,6 @@ INITAL_TAB = """
0,30 * * * * firstcommand
"""

class UserTestCase(unittest.TestCase):
    def test_01_self_user(self):
        tab = crontab.CronTab(user='foo')
        self.assertEqual(tab.user_opt, {'u': 'foo'})
        tab = crontab.CronTab(user=crontab.current_user())
        self.assertEqual(tab.user_opt, {})


class CompatTestCase(unittest.TestCase):
    """Test basic functionality of crontab."""
    @classmethod
+15 −0
Original line number Diff line number Diff line
@@ -78,6 +78,21 @@ class UseTestCase(unittest.TestCase):
        self.assertEqual(cron.render(), BASIC)
        self.assertEqual(repr(cron), "<User CronTab 'basic'>")

    def test_02_user_bad_command(self):
        # Test bad cron command
        cron = crontab.CronTab(user='basic')
        cron.cron_command = 'wibble/no/no/no/yes'
        with self.assertRaises(IOError):
            cron.read()
        with self.assertRaises(IOError):
            cron.write()

    def test_02_user_self(self):
        tab = crontab.CronTab(user='foo')
        self.assertEqual(tab.user_opt, {'u': 'foo'})
        tab = crontab.CronTab(user=crontab.current_user())
        self.assertEqual(tab.user_opt, {})

    def test_03_usage(self):
        """Dont modify crontab"""
        cron = crontab.CronTab(tab='')