def test_shot_add_instance_fail(shot, instance_shot): # Expect to fail with InstanceNameExists error. try: Instance.add_instance(shot, instance_shot.asset, instance_shot.name) except InstanceNameExists: return raise AssertionError('Expected a InstanceNameExists due to instance name exists')
def instance_shot(shot, asset): try: return Instance.find_one(project=shot.project, entity=shot, asset=asset, name='instance01') except NoResultFound: return Instance.create(project=shot.project, entity=shot, asset=asset, name='instance01')
def test_create_bad_arguments_asset(instance_shot): # Expecting TypeError error, wrong argument/entity given. try: Instance.create(project=instance_shot.project, name=instance_shot.name, asset=instance_shot.asset, entity=instance_shot.asset) except TypeError: return raise AssertionError('Expected TypeError due to wrong arg type')
def test_create_unique_seq_name(instance_sequence): # Expecting IntegrityError error "Duplicate entry..." try: Instance.create(project=instance_sequence.project, name=instance_sequence.name, asset=instance_sequence.asset, entity=instance_sequence.parent) except IntegrityError: return raise AssertionError('Expected IntegrityError due to "Duplicate entry"')
def test_findby_name(instance_shot): assert instance_shot == Instance.find_one(project=instance_shot.project, entity=instance_shot.shot, name=instance_shot.name)
def test_find_one(instance_shot): assert instance_shot == Instance.find_one(id=instance_shot.id)
def test_findby_ids(instance_shot): assert instance_shot in Instance.findby_ids([instance_shot.id])
def test_find(instance_shot): assert instance_shot in Instance.find()
def test_cls_name(): assert Instance.cls_name() == 'Instance'
def test_sequence_add_instance(sequence, asset): Instance.add_instance(sequence, asset, asset.name + 'new_1')
def test_shot_add_instance(shot, asset): Instance.add_instance(shot, asset, asset.name + 'new_1')