Example #1
0
 def testOverValueKeyPath(self):
     self.assertEqual(
         DirectString,
         STUB.keyValue_forObject_key_(
             DO_VALUEFORKEYPATH, self.path, "overDirectHead.directString"
         ),
     )
     self.assertEqual(
         DirectString,
         STUB.keyValue_forObject_key_(
             DO_VALUEFORKEYPATH, self.path, "overIndirectHead.directString"
         ),
     )
     self.assertEqual(
         IndirectString,
         STUB.keyValue_forObject_key_(
             DO_VALUEFORKEYPATH, self.path, "overDirectHead.indirectString"
         ),
     )
     self.assertEqual(
         IndirectString,
         STUB.keyValue_forObject_key_(
             DO_VALUEFORKEYPATH, self.path, "overIndirectHead.indirectString"
         ),
     )
Example #2
0
    def testValueForKeyPath(self):
        o = KeyValueClass2()
        o.addMultiple()

        self.assertEqual(
            STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, o, "multiple"),
            o.multiple)
        self.assertEqual(
            STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, o,
                                         "multiple.level2"),
            o.multiple.level2,
        )
        self.assertEqual(
            STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, o,
                                         "multiple.level2.level3.keyA"),
            o.multiple.level2.level3.keyA,
        )
        self.assertEqual(
            STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, o,
                                         "multiple.level2.level3.keyB"),
            o.multiple.level2.level3.keyB,
        )

        self.assertRaises(
            KeyError,
            STUB.keyValue_forObject_key_,
            DO_VALUEFORKEYPATH,
            o,
            "multiple.level2.nokey",
        )
Example #3
0
 def testOverValueKey(self):
     self.assertEqual(
         DirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base,
                                      "overDirectString"))
     self.assertEqual(
         IndirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base,
                                      "overIndirectString"))
Example #4
0
 def testBaseValueForKey(self):
     self.assertEquals(DirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base, u"directString"))
     self.assertEquals(IndirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base, u"indirectString"))
     self.assertEquals(DirectNumber,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base, u"directNumber"))
     self.assertEquals(IndirectNumber,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base, u"indirectNumber"))
Example #5
0
 def testBaseValueForKey(self):
     self.assertEqual(DirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base, "directString"))
     self.assertEqual(IndirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base, "indirectString"))
     self.assertEqual(DirectNumber,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base, "directNumber"))
     self.assertEqual(IndirectNumber,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base, "indirectNumber"))
Example #6
0
 def testOverValueKeyPath(self):
     self.assertEquals(DirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, u"overDirectHead.directString"))
     self.assertEquals(DirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, u"overIndirectHead.directString"))
     self.assertEquals(IndirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, u"overDirectHead.indirectString"))
     self.assertEquals(IndirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, u"overIndirectHead.indirectString"))
Example #7
0
    def testValueForKeyPath(self):
        o = KeyValueClass2()
        o.addMultiple()

        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, o, u"multiple"), o.multiple)
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, o, u"multiple.level2"), o.multiple.level2)
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, o, u"multiple.level2.level3.keyA"), o.multiple.level2.level3.keyA)
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, o, u"multiple.level2.level3.keyB"), o.multiple.level2.level3.keyB)

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, DO_VALUEFORKEYPATH, o, u"multiple.level2.nokey")
Example #8
0
    def testStoredValueForKey(self):
        o = KeyValueClass2()
        o.addMultiple()

        self.assertEquals(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, u"key1"), 1)
        self.assertEquals(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, u"key2"), 2)
        self.assertEquals(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, u"key3"), 3)
        self.assertEquals(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, u"key4"), u"4")
        self.assertEquals(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, u"multiple"), o.multiple)

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, DO_STOREDVALUEFORKEY, o, u"nokey")
Example #9
0
    def testValueForKey2(self):
        o = KeyValueClass3()

        self.assertEqual(
            STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "foo"), "foobar")
        self.assertEqual(
            STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "bar"),
            "foobarfoobar")
        self.assertEqual(
            STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "roprop"),
            "read-only")
Example #10
0
    def testStoredValueForKey(self):
        o = KeyValueClass2()
        o.addMultiple()

        self.assertEqual(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, "key1"), 1)
        self.assertEqual(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, "key2"), 2)
        self.assertEqual(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, "key3"), 3)
        self.assertEqual(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, "key4"), "4")
        self.assertEqual(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, "multiple"), o.multiple)

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, DO_STOREDVALUEFORKEY, o, "nokey")
Example #11
0
        def testPythonConvention(self):
            o = KeyValueClass2()

            self.assertEquals(o._pythonConvention, u'BAD')
            self.assertEquals(o.pythonConvention(), u'GOOD')
            self.assertEquals(o._pythonConventionValue, u'GOOD')
            self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"pythonConvention"), u'GOOD')
            STUB.setKeyValue_forObject_key_value_(DO_SETVALUE_FORKEY, o, u'pythonConvention', u'CHANGED')
            self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"pythonConvention"), u'CHANGED')
            self.assertEquals(o._pythonConvention, u'BAD')
            self.assertEquals(o.pythonConvention(), u'CHANGED')
            self.assertEquals(o._pythonConventionValue, u'CHANGED')
        def testPythonConvention(self):
            o = KeyValueClass2()

            self.assertEqual(o._pythonConvention, "BAD")
            self.assertEqual(o.pythonConvention(), "GOOD")
            self.assertEqual(o._pythonConventionValue, "GOOD")
            self.assertEqual(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "pythonConvention"), "GOOD")
            STUB.setKeyValue_forObject_key_value_(DO_SETVALUE_FORKEY, o, "pythonConvention", "CHANGED")
            self.assertEqual(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "pythonConvention"), "CHANGED")
            self.assertEqual(o._pythonConvention, "BAD")
            self.assertEqual(o.pythonConvention(), "CHANGED")
            self.assertEqual(o._pythonConventionValue, "CHANGED")
Example #13
0
        def testPythonConvention(self):
            o = KeyValueClass2()

            self.assertEqual(o._pythonConvention, 'BAD')
            self.assertEqual(o.pythonConvention(), 'GOOD')
            self.assertEqual(o._pythonConventionValue, 'GOOD')
            self.assertEqual(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "pythonConvention"), 'GOOD')
            STUB.setKeyValue_forObject_key_value_(DO_SETVALUE_FORKEY, o, 'pythonConvention', 'CHANGED')
            self.assertEqual(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "pythonConvention"), 'CHANGED')
            self.assertEqual(o._pythonConvention, 'BAD')
            self.assertEqual(o.pythonConvention(), 'CHANGED')
            self.assertEqual(o._pythonConventionValue, 'CHANGED')
 def testPathValueForKey(self):
     self.assertEqual(
         DirectString, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "directHead.directString")
     )
     self.assertEqual(
         DirectString, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "indirectHead.directString")
     )
     self.assertEqual(
         IndirectString, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "directHead.indirectString")
     )
     self.assertEqual(
         IndirectString, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "indirectHead.indirectString")
     )
     self.assertEqual(
         DirectNumber, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "directHead.directNumber")
     )
     self.assertEqual(
         DirectNumber, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "indirectHead.directNumber")
     )
     self.assertEqual(
         IndirectNumber, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "directHead.indirectNumber")
     )
     self.assertEqual(
         IndirectNumber, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "indirectHead.indirectNumber")
     )
Example #15
0
 def testPathValueForKey(self):
     self.assertEqual(
         DirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path,
                                      "directHead.directString"))
     self.assertEqual(
         DirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path,
                                      "indirectHead.directString"))
     self.assertEqual(
         IndirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path,
                                      "directHead.indirectString"))
     self.assertEqual(
         IndirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path,
                                      "indirectHead.indirectString"))
     self.assertEqual(
         DirectNumber,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path,
                                      "directHead.directNumber"))
     self.assertEqual(
         DirectNumber,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path,
                                      "indirectHead.directNumber"))
     self.assertEqual(
         IndirectNumber,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path,
                                      "directHead.indirectNumber"))
     self.assertEqual(
         IndirectNumber,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path,
                                      "indirectHead.indirectNumber"))
Example #16
0
    def testStrCap(self):
        class Foo:
            def callme(self):
                return "FOO"

        # check the result for valueForKey: "callme" on a Foo instance
        self.assertEqual(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, Foo(), "callme"), "FOO")
Example #17
0
    def testStrCap(self):
        class Foo:
            def callme(self):
                return u"FOO"

        # check the result for valueForKey: u"callme" on a Foo instance
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, Foo(), u"callme"), u"FOO")
Example #18
0
        def testPythonConvention(self):
            o = KeyValueClass2()

            self.assertEqual(o._pythonConvention, "BAD")
            self.assertEqual(o.pythonConvention(), "GOOD")
            self.assertEqual(o._pythonConventionValue, "GOOD")
            self.assertEqual(
                STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "pythonConvention"),
                "GOOD",
            )
            STUB.setKeyValue_forObject_key_value_(
                DO_SETVALUE_FORKEY, o, "pythonConvention", "CHANGED"
            )
            self.assertEqual(
                STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "pythonConvention"),
                "CHANGED",
            )
            self.assertEqual(o._pythonConvention, "BAD")
            self.assertEqual(o.pythonConvention(), "CHANGED")
            self.assertEqual(o._pythonConventionValue, "CHANGED")
    def testValuesForKeys(self):
        o = KeyValueClass2()

        self.assertEqual(
            STUB.keyValue_forObject_key_(DO_VALUESFORKEYS, o, ["key1", "key2", "key3", "key4"]),
            {"key1": 1, "key2": 2, "key3": 3, "key4": "4"},
        )

        self.assertRaises(
            KeyError, STUB.keyValue_forObject_key_, DO_VALUESFORKEYS, o, ["key1", "key2", "nokey", "key3"]
        )
Example #20
0
    def testValuesForKeys(self):
        o = KeyValueClass2()

        self.assertEqual(
            STUB.keyValue_forObject_key_(DO_VALUESFORKEYS, o,
                                         ["key1", "key2", "key3", "key4"]), {
                                             "key1": 1,
                                             "key2": 2,
                                             "key3": 3,
                                             "key4": "4"
                                         })

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_,
                          DO_VALUESFORKEYS, o,
                          ["key1", "key2", "nokey", "key3"])
Example #21
0
    def testValueForKey(self):
        o = KeyValueClass2()
        o.addMultiple()

        self.assertEqual(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "key1"), 1)
        self.assertEqual(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "key2"), 2)
        self.assertEqual(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "key3"), 3)
        self.assertEqual(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "key4"), "4")
        self.assertEqual(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "multiple"), o.multiple)
        self.assertEqual(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "pythonConvention"), 'GOOD')

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, DO_VALUEFORKEY, o, "nokey")
Example #22
0
    def testValueForKey(self):
        o = KeyValueClass2()
        o.addMultiple()

        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"key1"), 1)
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"key2"), 2)
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"key3"), 3)
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"key4"), u"4")
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"multiple"), o.multiple)
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"pythonConvention"), u'GOOD')

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, DO_VALUEFORKEY, o, u"nokey")
Example #23
0
 def testOverValueKey(self):
     self.assertEquals(DirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base, u"overDirectString"))
     self.assertEquals(IndirectString,
         STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base, u"overIndirectString"))
Example #24
0
    def testStoredValueForKey2(self):
        o = KeyValueClass3()

        self.assertEqual(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, "foo"), "foobar")
        self.assertEqual(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, "bar"), "foobarfoobar")
        self.assertEqual(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, "roprop"), "read-only")
    def testStoredValueForKey2(self):
        o = KeyValueClass3()

        self.assertEquals(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, u"foo"), u"foobar")
        self.assertEquals(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, u"bar"), u"foobarfoobar")
        self.assertEquals(STUB.keyValue_forObject_key_(DO_STOREDVALUEFORKEY, o, u"roprop"), u"read-only")
Example #26
0
    def testValueForKey2(self):
        o = KeyValueClass3()

        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"foo"), u"foobar")
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"bar"), u"foobarfoobar")
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"roprop"), u"read-only")