def it_requires_a_mapped_class_or_instance(): with expect.raises(TypeError): utilities.find(Mock)
def it_returns_none_when_no_match(model_class): expect(utilities.find(model_class, 'not', 'here')) == None
def it_allows_objects_to_be_created(model_class): expect(utilities.find(model_class, 'new', 'one', create=True)) == \ model_class('new', 'one')
def it_supports_keyword_arguments(model_class, instance): instance.__mapper__.create() expect(utilities.find(model_class, 'foo', key='bar')) == instance
def it_returns_object_when_found(model_class, instance): instance.__mapper__.create() expect(utilities.find(model_class, 'foo', 'bar')) == instance
def find(cls, *args, **kwargs): return utilities.find(cls, *args, **kwargs)