コード例 #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())