def test_simple(self):
		rs = RuleSet(*rule_types)
		rs.add_rule(('is', 'big'), big_thing)

		objects = [Thing('foo'), Thing('bar'), Thing('big', number=20)]
		self.session.add_all(objects)
		self.session.commit()
		objects = self.session.query(Thing)

		for o, (big,) in rs.with_permissions(objects, ('is', 'big')):
			self.assertEqual(o.number > 10, big)
    def test_simple(self):
        rs = RuleSet(*rule_types)
        rs.add_rule(('is', 'big'), big_thing)

        objects = [Thing('foo'), Thing('bar'), Thing('big', number=20)]
        self.session.add_all(objects)
        self.session.commit()
        objects = self.session.query(Thing)

        for o, (big, ) in rs.with_permissions(objects, ('is', 'big')):
            self.assertEqual(o.number > 10, big)
    def test_other_types(self):
        rs = RuleSet(*rule_types)
        rs.add_rule(('is', 'big'), big_thing)
        rs.add_rule(('is', 'b'), b_name)
        rs.add_rule(('is', 'f'), f_name)

        objects = [Thing('foo'), Thing('bar'), Thing('big', number=20)]
        self.session.add_all(objects)
        self.session.commit()
        objects = self.session.query(Thing)

        for o, (big, b, f) in rs.with_permissions(objects, ('is', 'big'),
                                                  ('is', 'b'), ('is', 'f')):
            self.assertEqual(o.number > 10, big)
            self.assertEqual(o.name[0] == 'b', b)
            self.assertEqual(o.name[0] == 'f', f)
	def test_other_types(self):
		rs = RuleSet(*rule_types)
		rs.add_rule(('is', 'big'), big_thing)
		rs.add_rule(('is', 'b'), b_name)
		rs.add_rule(('is', 'f'), f_name)

		objects = [Thing('foo'), Thing('bar'), Thing('big', number=20)]
		self.session.add_all(objects)
		self.session.commit()
		objects = self.session.query(Thing)

		for o, (big, b, f) in rs.with_permissions(objects, ('is', 'big'), ('is', 'b'), ('is', 'f')):
			self.assertEqual(o.number > 10, big)
			self.assertEqual(o.name[0] == 'b', b)
			self.assertEqual(o.name[0] == 'f', f)
	def test_rule_inference(self):
		rs = RuleSet(*rule_types)
		rs.add_rule(('foo',), big_thing)
		self.assertEqual(rs.rules[QueryRuleSet]['foo',], {big_thing})
 def test_rule_inference(self):
     rs = RuleSet(*rule_types)
     rs.add_rule(('foo', ), big_thing)
     self.assertEqual(rs.rules[QueryRuleSet]['foo', ], {big_thing})