示例#1
0
    def test__check_resource_incorrect_resource(self):
        class OneType(resource2.Resource):
            pass

        class AnotherType(resource2.Resource):
            pass

        value = AnotherType()
        decorated = proxy2._check_resource(strict=False)(self.sot.method)
        self.assertRaisesRegexp(ValueError,
                                "Expected OneType but received AnotherType",
                                decorated, self.sot, OneType, value)
示例#2
0
    def test__check_resource_incorrect_resource(self):
        class OneType(resource2.Resource):
            pass

        class AnotherType(resource2.Resource):
            pass

        value = AnotherType()
        decorated = proxy2._check_resource(strict=False)(self.sot.method)
        self.assertRaisesRegexp(ValueError,
                                "Expected OneType but received AnotherType",
                                decorated, self.sot, OneType, value)
示例#3
0
 def test__check_resource_strict_id(self):
     decorated = proxy2._check_resource(strict=True)(self.sot.method)
     self.assertRaisesRegexp(ValueError, "A Resource must be passed",
                             decorated, self.sot, resource2.Resource,
                             "this-is-not-a-resource")
示例#4
0
    def _test_correct(self, value):
        decorated = proxy2._check_resource(strict=False)(self.sot.method)
        rv = decorated(self.sot, resource2.Resource, value)

        self.assertEqual(value, rv)
示例#5
0
 def test__check_resource_strict_id(self):
     decorated = proxy2._check_resource(strict=True)(self.sot.method)
     self.assertRaisesRegexp(ValueError, "A Resource must be passed",
                             decorated, self.sot, resource2.Resource,
                             "this-is-not-a-resource")
示例#6
0
    def _test_correct(self, value):
        decorated = proxy2._check_resource(strict=False)(self.sot.method)
        rv = decorated(self.sot, resource2.Resource, value)

        self.assertEqual(value, rv)