Ejemplo n.º 1
0
 def with_class_and_partial_match(model_class, instances):
     matches = list(
         utilities.match(
             model_class,
             kind='spam',
         )
     )
     expect(len(matches)) == 2
     for instance in matches:
         expect(instance.kind) == 'spam'
         expect(instances).contains(instance)
Ejemplo n.º 2
0
 def with_self_string_and_partial_match(model_class, instances):
     matches = list(
         utilities.match(
             "data/{self.kind}/{self.key}.yml",
             (lambda key, kind: model_class(kind, key, test="test")),
             kind='egg',
         )
     )
     expect(len(matches)) == 2
     for instance in matches:
         expect(instance.kind) == 'egg'
         expect(instances).contains(instance)
Ejemplo n.º 3
0
 def with_class_and_no_factory(model_class, instances):
     matches = list(
         utilities.match(
             model_class,
             kind='spam',
             key='foo',
         )
     )
     expect(len(matches)) == 1
     instance = matches[0]
     expect(instance.kind) == 'spam'
     expect(instance.key) == 'foo'
     expect(instances).contains(instance)
Ejemplo n.º 4
0
 def with_self_string(model_class, instances):
     matches = list(
         utilities.match(
             "data/{self.kind}/{self.key}.yml",
             (lambda key, kind: model_class(kind, key, test="test")),
             kind='spam',
             key='bar',
         )
     )
     expect(len(matches)) == 1
     instance = matches[0]
     expect(instance.kind) == 'spam'
     expect(instance.key) == 'bar'
     expect(instances).contains(instance)
Ejemplo n.º 5
0
 def with_class_and_factory(model_class, instances):
     matches = list(
         utilities.match(
             model_class,
             (lambda key, kind: model_class(kind, key, test="test")),
             kind='spam',
             key='foo',
         )
     )
     expect(len(matches)) == 1
     instance = matches[0]
     expect(instance.kind) == 'spam'
     expect(instance.key) == 'foo'
     expect(instances).contains(instance)
Ejemplo n.º 6
0
 def it_is_not_yet_implemented():
     with expect.raises(NotImplementedError):
         utilities.match(Mock)
Ejemplo n.º 7
0
 def match(cls, *args, **kwargs):
     return utilities.match(cls, *args, **kwargs)
Ejemplo n.º 8
0
 def it_is_not_yet_implemented():
     with expect.raises(NotImplementedError):
         utilities.match(Mock)