Пример #1
0
    def withPrefix(self):
        a = ItemId("Test")
        b = a.withPrefix(2)
        self.assertEqual(b.name, "2Test")

        b = a.withSuffix("Two")
        self.assertEqual(b.name, "TwoTest")
Пример #2
0
    def testWithSuffix(self):
        a = ItemId("Test")
        b = a.withSuffix(2)
        self.assertEqual(b.name, "Test2")

        b = a.withSuffix("Two")
        self.assertEqual(b.name, "TestTwo")
Пример #3
0
    def testToFromSetting(self):
        i1 = ItemId("Blah")
        setting = i1.toSetting()
        self.assertIsNotNone(setting)

        # [...]

        i2 = ItemId.fromSetting(setting)
        self.assertEqual(i1.name, i2.name, "'{}' and restored '{}' do not match".format(
            i1.name, i2.name))
Пример #4
0
    def testCompareIdsById(self):
        a = ItemId("Foo")
        b = ItemId("Foo")
        print(a.uniqueIdentifier, b.uniqueIdentifier)
        self.assertTrue(a == b)
        self.assertFalse(a != b)

        setting = a.toSetting()
        c = ItemId.fromSetting(setting)

        self.assertTrue(a == c)
Пример #5
0
    def testAlphabeticallyBefore(self):
        a = ItemId("alpha")
        b = ItemId("beta")
        b2 = ItemId("Beta")

        self.assertTrue(a.alphabeticallyBefore(b))
        self.assertFalse(b.alphabeticallyBefore(a))
        self.assertFalse(b.alphabeticallyBefore(b2))
        self.assertTrue(b2.alphabeticallyBefore(b))
Пример #6
0
    def registerAction(self, action, actionId: ItemId, context: IContext, scriptable: bool) -> Command:
        """Makes a shortcut known to the system under the specified id.
        Returns a command object that represents the shortcut in the application and is
        owned by the ActionManager. You can register several shortcuts with the
        same id as long as the context is different. In this case
        a trigger of the actual shortcut is forwarded to the registered QShortcut
        for the currently active context.
        A scriptable shortcut can be called from a script without the need for the user
        to interact with it."""

        a = self.__overridableAction(actionId)
        if a is not None:
            a.addOverrideAction(action, context, scriptable)
            self.instance.commandListChanged.emit()
            self.instance.commandAdded(actionId.toSetting())
        return a
Пример #7
0
 def testSuffixAfter(self):
     a = ItemId("Test")
     b = a.withSuffix("Blah")
     self.assertEqual(b.suffixAfter(a), "Blah")
Пример #8
0
 def testToSetting(self):
     i = ItemId("Foo")
     self.assertEqual(i.toSetting(), "Foo")
Пример #9
0
 def testCreation(self):
     i = ItemId("Test")
     self.assertEqual(i.name, "Test")
     self.assertTrue(i.isValid())