Пример #1
0
    def testHasProxy(self):
        """ModelTest: Test hasProxy()"""
        # Create proxies
        model1 = Model.getInstance(self.KEY1)
        model2 = Model.getInstance(self.KEY2)

        proxy1 = Proxy("aces", ["clubs", "spades", "hearts", "diamonds"])
        proxy2 = Proxy("directions", ["north", "south", "east", "west"])

        # Register proxies
        model1.registerProxy(proxy1)
        model2.registerProxy(proxy2)

        self.assertEqual(True, model1.hasProxy('aces'))
        self.assertEqual(False, model2.hasProxy('aces'))

        self.assertEqual(True, model2.hasProxy('directions'))
        self.assertEqual(False, model1.hasProxy('directions'))

        # Remove proxies
        model1.removeProxy('aces')
        model2.removeProxy('directions')

        self.assertEqual(False, model1.hasProxy('aces'))
        self.assertEqual(False, model2.hasProxy('directions'))
Пример #2
0
    def __init__(self, data=None):
        Proxy.__init__(self, self.NAME, _prefs.prefs)

        # load saved config
        self.load('config.xml')

        # export prefs instance into model module
        model.prefs = self
    def testDataAccessors(self):
        """ProxyTest: Test Data Accessors"""

        prxy = Proxy('colors')
        prxy.setData(['red', 'green', 'blue'])
        data = prxy.getData()

        self.assertEqual(True, len(data) == 3)
        self.assertEqual(True, data[0] == 'red')
        self.assertEqual(True, data[1] == 'green')
        self.assertEqual(True, data[2] == 'blue')
    def testDataAccessors(self):
        """ProxyTest: Test Data Accessors"""

        prxy = Proxy('colors')
        prxy.setData(['red', 'green', 'blue'])
        data = prxy.getData()

        self.assertEqual(True, len(data) == 3)
        self.assertEqual(True, data[0] == 'red')
        self.assertEqual(True, data[1] == 'green')
        self.assertEqual(True, data[2] == 'blue')
    def testConstructor(self):
        """ProxyTest: Test Constructor"""

        prxy = Proxy('colors', ['red', 'green', 'blue'])
        data = prxy.getData()

        self.assertEqual(True, prxy is not None)
        self.assertEqual(True, prxy.getProxyName() == 'colors')
        self.assertEqual(True, len(data) == 3)
        self.assertEqual(True, data[0] == 'red')
        self.assertEqual(True, data[1] == 'green')
        self.assertEqual(True, data[2] == 'blue')
    def testConstructor(self):
        """ProxyTest: Test Constructor"""

        prxy = Proxy('colors', ['red', 'green', 'blue'])
        data = prxy.getData()

        self.assertEqual(True, prxy is not None)
        self.assertEqual(True, prxy.getProxyName() == 'colors')
        self.assertEqual(True, len(data) == 3)
        self.assertEqual(True, data[0] == 'red')
        self.assertEqual(True, data[1] == 'green')
        self.assertEqual(True, data[2] == 'blue')
    def testEmptyData(self):
        """ProxyTest: Test Constructor with not-null empty data"""

        values = ["", (), []]

        for value in values:
            proxy = Proxy("empty", value)

            self.assertEqual(proxy.data, value)
Пример #8
0
    def testRegisterAndRemoveProxy(self):
        """ModelTest: Test registerProxy() and removeProxy()"""
        model = Model.getInstance(self.KEY1)
        testProxy = Proxy('sizes', ['7', '13', '21'])
        model.registerProxy(testProxy)

        removedProxy = model.removeProxy('sizes')

        self.assertEqual(True, removedProxy.getProxyName() == 'sizes')

        testProxy = model.retrieveProxy('sizes')

        self.assertEqual(None, testProxy)
Пример #9
0
    def testRegisterAndRetrieveProxy(self):
        """ModelTest: Test registerProxy() and retrieveProxy()"""
        model = Model.getInstance(self.KEY1)
        model.registerProxy(Proxy('colors', ['red', 'green', 'blue']))

        testProxy = model.retrieveProxy('colors')
        data = testProxy.getData()

        self.assertNotEqual(None, data)
        self.assertEqual(True, isinstance(data, list))
        self.assertEqual(True, len(data) == 3)
        self.assertEqual(True, data[0] == 'red')
        self.assertEqual(True, data[1] == 'green')
        self.assertEqual(True, data[2] == 'blue')
    def testNameAccessor(self):
        """ProxyTest: Test Name Accessor"""

        prxy = Proxy('TestProxy')
        self.assertEqual(True, prxy.getProxyName() == 'TestProxy')
    def testNameAccessor(self):
        """ProxyTest: Test Name Accessor"""

        prxy = Proxy('TestProxy')
        self.assertEqual(True, prxy.getProxyName() == 'TestProxy')
    def testHasMultitonKey(self):
        """ProxyTest: has multiton key"""
        prxy = Proxy("multitonKey")

        self.assertTrue(hasattr(prxy, "multitonKey"))
Пример #13
0
 def __init__(self):
     Proxy.__init__(self, PrefsProxy.NAME, model.Prefs)
Пример #14
0
 def __init__(self):
     Proxy.__init__(self, EnvProxy.NAME)
Пример #15
0
 def __getattr__(self, name):
     try:
         return self.data.__getattribute__(name)
     except:
         return Proxy.__getattribute__(self, name)