示例#1
0
文件: test_id.py 项目: nerdocs/MedUX
    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
文件: test_id.py 项目: nerdocs/MedUX
    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
文件: test_id.py 项目: nerdocs/MedUX
    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
文件: test_id.py 项目: nerdocs/MedUX
    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
文件: test_id.py 项目: nerdocs/MedUX
    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
文件: __init__.py 项目: nerdocs/MedUX
    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
文件: test_id.py 项目: nerdocs/MedUX
 def testSuffixAfter(self):
     a = ItemId("Test")
     b = a.withSuffix("Blah")
     self.assertEqual(b.suffixAfter(a), "Blah")
示例#8
0
文件: test_id.py 项目: nerdocs/MedUX
 def testToSetting(self):
     i = ItemId("Foo")
     self.assertEqual(i.toSetting(), "Foo")
示例#9
0
文件: test_id.py 项目: nerdocs/MedUX
 def testCreation(self):
     i = ItemId("Test")
     self.assertEqual(i.name, "Test")
     self.assertTrue(i.isValid())