Beispiel #1
0
 def test_get_unique_filename(self):
     system = System()
     self.assertNotEqual(system.get_unique_filename("a/b"),
                         system.get_unique_filename("a%47b"))
     self.assertNotEqual(system.get_unique_filename("a%b"),
                         system.get_unique_filename("a%37b"))
     self.assertNotEqual(system.get_unique_filename("a%/b"),
                         system.get_unique_filename("a%37%3747b"))
     self.assertEqual("a b", system.get_unique_filename("a b"))
Beispiel #2
0
 def testGetUniqueFilename(self):
     system = System()
     self.assertNotEqual(system.getUniqueFilename("a/b"),
                         system.getUniqueFilename("a%47b"))
     self.assertNotEqual(system.getUniqueFilename("a%b"),
                         system.getUniqueFilename("a%37b"))
     self.assertNotEqual(system.getUniqueFilename("a%/b"),
                         system.getUniqueFilename("a%37%3747b"))
     self.assertEqual("a b", system.getUniqueFilename("a b"))
Beispiel #3
0
    def testRemovingSystemPresets(self):
        self.manager.loadAll()
        system_presets = list(self.manager.presets.keys())
        for preset_name in system_presets:
            self.manager.restorePreset(preset_name)
            self.manager.removeCurrentPreset()

        # Check that the files have not been deleted or changed.
        other_manager = AudioPresetManager(System())
        other_manager.user_path = "/pitivi/non/existing/directory"
        other_manager.loadAll()
        for preset_name in system_presets:
            self.assertTrue(other_manager.hasPreset(preset_name))

        # Check that overwrite files have been created and
        # they mark the system presets as deleted.
        other_manager = self.createOtherManager()
        other_manager.loadAll()
        for preset_name in system_presets:
            self.assertFalse(other_manager.hasPreset(preset_name))
Beispiel #4
0
    def testRenamingSystemPresets(self):
        self.manager.loadAll()
        system_presets = list(self.manager.presets.keys())
        new_name_template = "%s new"
        for preset_name in system_presets:
            self.manager.restorePreset(preset_name)
            new_name = new_name_template % preset_name
            self.manager.saveCurrentPreset(new_name)

        # Check that the files have not been deleted or changed.
        other_manager = AudioPresetManager(System())
        other_manager.user_path = "/pitivi/non/existing/directory"
        other_manager.loadAll()
        for preset_name in system_presets:
            self.assertTrue(other_manager.hasPreset(preset_name), preset_name)

        other_manager = self.createOtherManager()
        other_manager.loadAll()
        for preset_name in system_presets:
            self.assertFalse(other_manager.hasPreset(preset_name), preset_name)
            new_name = new_name_template % preset_name
            self.assertTrue(other_manager.hasPreset(new_name), new_name)
Beispiel #5
0
 def setUp(self):
     self.manager = PresetManager(None, tempfile.mkdtemp(), System())
     self.manager._serializePreset = lambda preset: dict(preset.items())
Beispiel #6
0
 def createOtherManager(self):
     other_manager = AudioPresetManager(System())
     other_manager.user_path = self.manager.user_path
     return other_manager
Beispiel #7
0
 def setUp(self):
     self.manager = AudioPresetManager(System())
     self.manager.user_path = tempfile.mkdtemp()
Beispiel #8
0
 def setUp(self):
     self.system = System()
Beispiel #9
0
class TestSystem(TestCase):

    def setUp(self):
        self.system = System()

    def testGetUniqueFilename(self):
        self.assertNotEqual(self.system.getUniqueFilename("a/b"),
                            self.system.getUniqueFilename("a%47b"))
        self.assertNotEqual(self.system.getUniqueFilename("a%b"),
                            self.system.getUniqueFilename("a%37b"))
        self.assertNotEqual(self.system.getUniqueFilename("a%/b"),
                            self.system.getUniqueFilename("a%37%3747b"))
        self.assertEqual("a b", self.system.getUniqueFilename("a b"))

    def testScreensaverInhibit(self):
        # check that we start of uninhibited
        self.assertTrue(not self.system.screensaverIsInhibited())

        # inhibit and check that we are
        self.system.inhibitScreensaver("a")
        self.assertTrue(self.system.screensaverIsInhibited())
        # uninhibit and check that we are
        self.system.uninhibitScreensaver("a")
        self.assertTrue(not self.system.screensaverIsInhibited())

        # check that adding/removing is consistent with multiple keys
        for c in range(0, 5):
            self.system.inhibitScreensaver(str(c))
            self.assertTrue(self.system.screensaverIsInhibited(str(c)))

        for c in range(0, 5):
            self.system.uninhibitScreensaver(str(c))
            self.assertTrue(not self.system.screensaverIsInhibited(str(c)))

        self.assertTrue(not self.system.screensaverIsInhibited())

    def testSleepInhibit(self):
        # check that we start of uninhibited
        self.assertTrue(not self.system.sleepIsInhibited())

        # inhibit and check that we are
        self.system.inhibitSleep("a")
        self.assertTrue(self.system.sleepIsInhibited())
        # uninhibit and check that we are
        self.system.uninhibitSleep("a")
        self.assertTrue(not self.system.sleepIsInhibited())

        # check that adding/removing is consistent with multiple keys
        for c in range(0, 5):
            self.system.inhibitSleep(str(c))
            self.assertTrue(self.system.sleepIsInhibited(str(c)))

        for c in range(0, 5):
            self.system.uninhibitSleep(str(c))
            self.assertTrue(not self.system.sleepIsInhibited(str(c)))

        self.assertTrue(not self.system.sleepIsInhibited())
Beispiel #10
0
class TestSystem(TestCase):
    def setUp(self):
        self.system = System()

    def testScreensaverInhibit(self):
        #check that we start of uninhibited
        self.assertTrue(not self.system.screensaverIsInhibited())

        #inhibit and check that we are
        self.system.inhibitScreensaver("a")
        self.assertTrue(self.system.screensaverIsInhibited())
        #uninhibit and check that we are
        self.system.uninhibitScreensaver("a")
        self.assertTrue(not self.system.screensaverIsInhibited())

        #check that adding/removing is consistent with multiple keys
        for c in range(0, 5):
            self.system.inhibitScreensaver(str(c))
            self.assertTrue(self.system.screensaverIsInhibited(str(c)))

        for c in range(0, 5):
            self.system.uninhibitScreensaver(str(c))
            self.assertTrue(not self.system.screensaverIsInhibited(str(c)))

        self.assertTrue(not self.system.screensaverIsInhibited())

    def testSleepInhibit(self):
        #check that we start of uninhibited
        self.assertTrue(not self.system.sleepIsInhibited())

        #inhibit and check that we are
        self.system.inhibitSleep("a")
        self.assertTrue(self.system.sleepIsInhibited())
        #uninhibit and check that we are
        self.system.uninhibitSleep("a")
        self.assertTrue(not self.system.sleepIsInhibited())

        #check that adding/removing is consistent with multiple keys
        for c in range(0, 5):
            self.system.inhibitSleep(str(c))
            self.assertTrue(self.system.sleepIsInhibited(str(c)))

        for c in range(0, 5):
            self.system.uninhibitSleep(str(c))
            self.assertTrue(not self.system.sleepIsInhibited(str(c)))

        self.assertTrue(not self.system.sleepIsInhibited())
Beispiel #11
0
 def setUp(self):
     self.system = System()
Beispiel #12
0
class TestSystem(TestCase):
    def setUp(self):
        self.system = System()

    def testGetUniqueFilename(self):
        self.assertNotEqual(self.system.getUniqueFilename("a/b"),
                            self.system.getUniqueFilename("a%47b"))
        self.assertNotEqual(self.system.getUniqueFilename("a%b"),
                            self.system.getUniqueFilename("a%37b"))
        self.assertNotEqual(self.system.getUniqueFilename("a%/b"),
                            self.system.getUniqueFilename("a%37%3747b"))
        self.assertEqual("a b", self.system.getUniqueFilename("a b"))

    def testScreensaverInhibit(self):
        #check that we start of uninhibited
        self.assertTrue(not self.system.screensaverIsInhibited())

        #inhibit and check that we are
        self.system.inhibitScreensaver("a")
        self.assertTrue(self.system.screensaverIsInhibited())
        #uninhibit and check that we are
        self.system.uninhibitScreensaver("a")
        self.assertTrue(not self.system.screensaverIsInhibited())

        #check that adding/removing is consistent with multiple keys
        for c in range(0, 5):
            self.system.inhibitScreensaver(str(c))
            self.assertTrue(self.system.screensaverIsInhibited(str(c)))

        for c in range(0, 5):
            self.system.uninhibitScreensaver(str(c))
            self.assertTrue(not self.system.screensaverIsInhibited(str(c)))

        self.assertTrue(not self.system.screensaverIsInhibited())

    def testSleepInhibit(self):
        #check that we start of uninhibited
        self.assertTrue(not self.system.sleepIsInhibited())

        #inhibit and check that we are
        self.system.inhibitSleep("a")
        self.assertTrue(self.system.sleepIsInhibited())
        #uninhibit and check that we are
        self.system.uninhibitSleep("a")
        self.assertTrue(not self.system.sleepIsInhibited())

        #check that adding/removing is consistent with multiple keys
        for c in range(0, 5):
            self.system.inhibitSleep(str(c))
            self.assertTrue(self.system.sleepIsInhibited(str(c)))

        for c in range(0, 5):
            self.system.uninhibitSleep(str(c))
            self.assertTrue(not self.system.sleepIsInhibited(str(c)))

        self.assertTrue(not self.system.sleepIsInhibited())