Example #1
0
    def testGetUniquePresetName(self):
        preset_manager = PresetManager()
        name = ProjectSettingsDialog._getUniquePresetName(preset_manager)
        self.assertEqual('New Preset', name)

        preset_manager.addPreset(name, {})
        new_preset1 = ProjectSettingsDialog._getUniquePresetName(
            preset_manager)
        self.assertEqual('New Preset 1', new_preset1)

        # Intentionally add 'New Preset 2' before 'New Preset 1'.
        preset_manager.addPreset('New Preset 2', {})
        preset_manager.addPreset(new_preset1, {})
        new_preset3 = ProjectSettingsDialog._getUniquePresetName(
            preset_manager)
        self.assertEqual('New Preset 3', new_preset3)
Example #2
0
    def testGetUniquePresetName(self):
        preset_manager = PresetManager()
        name = ProjectSettingsDialog._getUniquePresetName(preset_manager)
        self.assertEqual('New Preset', name)

        preset_manager.addPreset(name, {})
        new_preset1 = ProjectSettingsDialog._getUniquePresetName(preset_manager)
        self.assertEqual('New Preset 1', new_preset1)

        # Intentionally add 'New Preset 2' before 'New Preset 1'.
        preset_manager.addPreset('New Preset 2', {})
        preset_manager.addPreset(new_preset1, {})
        new_preset3 = ProjectSettingsDialog._getUniquePresetName(preset_manager)
        self.assertEqual('New Preset 3', new_preset3)
Example #3
0
class TestPresetBasics(TestCase):

    def setUp(self):
        self.manager = PresetManager()
        self.user_path = tempfile.mkdtemp()
        self.manager.user_path = self.user_path  # Keep PresetManager happy

    def tearDown(self):
        # Delete the user directory we created (but not the default directory)
        shutil.rmtree(self.user_path)

    def testConvertPresetNameToSectionName(self):
        self.presetToSection = self.manager._convertPresetNameToSectionName
        self.assertEqual("my preset", self.presetToSection('my preset'))
        self.assertEqual("my preset_", self.presetToSection('my preset_'))
        self.assertEqual("default_x_", self.presetToSection('default_x_'))

        # Test that default_* preset names get a _ character at the end.
        self.assertEqual("Default_", self.presetToSection('Default'))
        self.assertEqual("defaulT__", self.presetToSection('defaulT_'))

    def testConvertSectionNameToPresetName(self):
        self.sectionToPreset = self.manager._convertSectionNameToPresetName
        self.assertEqual("my preset", self.sectionToPreset('my preset'))
        self.assertEqual("my preset_", self.sectionToPreset('my preset_'))
        self.assertEqual("default_x_", self.sectionToPreset('default_x_'))

        # Test that default_+ section names lose the last character.
        self.assertEqual("Default", self.sectionToPreset('Default_'))
        self.assertEqual("defaulT_", self.sectionToPreset('defaulT__'))

    def testAddPreset(self):
        self.manager.addPreset('preseT onE', {'name1': '1A'})
        self.assertRaises(DuplicatePresetNameException,
                self.manager.addPreset, 'Preset One', {'name1': '2A'})

    def testRenamePreset(self):
        self.manager.addPreset('preseT onE', {'name1': '1A'})
        self.manager.addPreset('Preset Two', {'name1': '2A'})

        # Renaming 'preseT onE' to 'Preset One'.
        self.manager.renamePreset('0', 'Preset One')

        # Renaming 'Preset One' to 'Preset TWO'.
        self.assertRaises(DuplicatePresetNameException,
                self.manager.renamePreset, '0', 'Preset TWO')
        # Renaming 'Preset One' to 'Preset two'.
        self.assertRaises(DuplicatePresetNameException,
                self.manager.renamePreset, '0', 'Preset two')
Example #4
0
 def setUp(self):
     self.manager = PresetManager()
     self.user_path = tempfile.mkdtemp()
     self.manager.user_path = self.user_path  # Keep PresetManager happy
Example #5
0
 def __init__(self, empty_dir):
     PresetManager.__init__(self)
     self.dir = empty_dir
Example #6
0
 def __init__(self, empty_dir):
     PresetManager.__init__(self)
     self.dir = empty_dir