def test_by_name(self): api = APIVersion('foo') class TestObject(Object): code = 'TEST' api.register(TestObject) result = api.TestObject compare(result, expected=TestObject)
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)
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
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')
def test_version_string(self): api = APIVersion('foo') compare(api.version, expected='foo')