Ejemplo n.º 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)
Ejemplo n.º 2
0
    def test_by_name(self):
        api = APIVersion('foo')

        class TestObject(Object):
            code = 'TEST'

        api.register(TestObject)

        result = api.TestObject

        compare(result, expected=TestObject)
Ejemplo n.º 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
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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
Ejemplo n.º 7
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')
Ejemplo n.º 8
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')