def test_collection_single(self): collection_constraint = TypedCollection(Exactly(self.A)) self.assertTrue(collection_constraint.satisfied_by([self.A()])) self.assertFalse( collection_constraint.satisfied_by([self.A(), self.B()])) self.assertTrue( collection_constraint.satisfied_by([self.A(), self.A()]))
def test_collection_multiple(self): collection_constraint = TypedCollection( SubclassesOf(self.B, self.BPrime)) self.assertTrue( collection_constraint.satisfied_by( [self.B(), self.C(), self.BPrime()])) self.assertFalse( collection_constraint.satisfied_by([self.B(), self.A()]))
def test_complex_sub_constraint(self): sub_collection = TypedCollection(Exactly(self.A)) nested_collection = TypedCollection(sub_collection) self.assertTrue(nested_collection.satisfied_by(())) self.assertTrue(nested_collection.satisfied_by([])) self.assertTrue(nested_collection.satisfied_by([[]])) self.assertTrue(nested_collection.satisfied_by([[self.A()]])) self.assertFalse(nested_collection.satisfied_by([[self.B()]]))
def test_collection_multiple(self): collection_constraint = TypedCollection(SubclassesOf(self.B, self.BPrime)) self.assertTrue(collection_constraint.satisfied_by([self.B(), self.C(), self.BPrime()])) self.assertFalse(collection_constraint.satisfied_by([self.B(), self.A()]))
def test_collection_single(self): collection_constraint = TypedCollection(Exactly(self.A)) self.assertTrue(collection_constraint.satisfied_by([self.A()])) self.assertFalse(collection_constraint.satisfied_by([self.A(), self.B()])) self.assertTrue(collection_constraint.satisfied_by([self.A(), self.A()]))