예제 #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())