Exemple #1
0
    def test_add_resource(self):
        def endpoint(self, params):
            pass

        resource = BaseResource(name='resource')
        resource.on_list = endpoint

        self.dispatcher.add_resource(resource)

        rules = list(self.dispatcher.url_map.iter_rules())

        self.assertEqual(len(rules), 1)
        self.assertEqual(rules[0].endpoint, endpoint)
Exemple #2
0
    def test_add_nested_resource_without_details(self):
        def endpoint(self, params):
            pass

        def nested_endpoint(self, params):
            pass

        resource = BaseResource(name='resource')
        resource.on_list = endpoint

        nested_resource = BaseResource(name='nested_resource')
        nested_resource.on_detail = nested_endpoint

        self.dispatcher.add_resource(resource)

        with self.assertRaises(AttributeError):
            self.dispatcher.add_resource(nested_resource, resource)