def test_incorrect_resource(self):
        class OneType(resource.Resource):
            pass

        class AnotherType(resource.Resource):
            pass

        value = AnotherType()
        decorated = proxy._check_resource(strict=False)(self.sot.method)
        self.assertRaisesRegex(ValueError,
                               "Expected OneType but received AnotherType",
                               decorated, self.sot, OneType, value)
Esempio n. 2
0
    def test__check_resource_incorrect_resource(self):
        class OneType(resource.Resource):
            pass

        class AnotherType(resource.Resource):
            pass

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

        self.assertEqual(value, rv)
 def test_strict_id(self):
     decorated = proxy._check_resource(strict=True)(self.sot.method)
     self.assertRaisesRegex(ValueError, "A Resource must be passed",
                            decorated, self.sot, resource.Resource,
                            "this-is-not-a-resource")
    def _test_correct(self, value):
        decorated = proxy._check_resource(strict=False)(self.sot.method)
        rv = decorated(self.sot, resource.Resource, value)

        self.assertEqual(value, rv)
Esempio n. 7
0
    def test_strict_None(self):
        # strict should only type check when `actual` is a value
        decorated = proxy._check_resource(strict=True)(self.sot.method)
        rv = decorated(self.sot, resource.Resource)

        self.assertIsNone(rv)