Exemple #1
0
    def test_by_name(self):
        api = APIVersion('foo')

        class TestObject(Object):
            code = 'TEST'

        api.register(TestObject)

        result = api.TestObject

        compare(result, expected=TestObject)
Exemple #2
0
    def test_from_data(self):
        api = APIVersion('foo')

        class TestObject(Object):
            code = 'TEST'

        api.register(TestObject)

        session = object()
        result = api.from_data(session, dict(x=1, objCode='TEST'))

        compare(result.session, session)
        compare(result.fields['x'], 1)
Exemple #3
0
    def setUp(self):
        super(TestObjectHelper, self).setUp()
        self.replace('workfront.session.Session.version_registry', {})
        test_api = APIVersion('test')

        class TestObject(Object):
            code = 'TEST'
            field_one = Field('fieldOne')
            field_two = Field('fieldTwo')

        test_api.register(TestObject)
        Session.register(test_api)
        self.session = Session('test', api_version='test')
        self.api = self.session.api
Exemple #4
0
    def test_override(self):
        api = APIVersion('foo')

        class TestObject(Object):
            code = 'TEST'

        api.register(TestObject)

        class TestObject_(TestObject):
            something = 'foo'

        api.override(TestObject, TestObject_)

        result = api.TestObject
        compare(result, expected=TestObject_)
        result = api.from_data(None, dict(objCode='TEST'))
        self.assertTrue(isinstance(result, TestObject_))
        compare(result.something, expected='foo')
Exemple #5
0
 def test_version_string(self):
     api = APIVersion('foo')
     compare(api.version, expected='foo')