Ejemplo n.º 1
0
 def it_requires_a_mapped_class_or_instance():
     with expect.raises(TypeError):
         utilities.find(Mock)
Ejemplo n.º 2
0
 def it_returns_none_when_no_match(model_class):
     expect(utilities.find(model_class, 'not', 'here')) == None
Ejemplo n.º 3
0
 def it_allows_objects_to_be_created(model_class):
     expect(utilities.find(model_class, 'new', 'one', create=True)) == \
         model_class('new', 'one')
Ejemplo n.º 4
0
    def it_supports_keyword_arguments(model_class, instance):
        instance.__mapper__.create()

        expect(utilities.find(model_class, 'foo', key='bar')) == instance
Ejemplo n.º 5
0
    def it_returns_object_when_found(model_class, instance):
        instance.__mapper__.create()

        expect(utilities.find(model_class, 'foo', 'bar')) == instance
Ejemplo n.º 6
0
 def find(cls, *args, **kwargs):
     return utilities.find(cls, *args, **kwargs)
Ejemplo n.º 7
0
 def it_requires_a_mapped_class_or_instance():
     with expect.raises(TypeError):
         utilities.find(Mock)
Ejemplo n.º 8
0
 def it_allows_objects_to_be_created(model_class):
     expect(utilities.find(model_class, 'new', 'one', create=True)) == \
         model_class('new', 'one')
Ejemplo n.º 9
0
 def it_returns_none_when_no_match(model_class):
     expect(utilities.find(model_class, 'not', 'here')) == None
Ejemplo n.º 10
0
    def it_returns_object_when_found(model_class, instance):
        instance.__mapper__.create()

        expect(utilities.find(model_class, 'foo', 'bar')) == instance