Example #1
0
    def test_url_for_nonexistent(self):
        """Tests that attempting to get the URL for an unknown model yields an
        error.

        """
        with self.assertRaises(ValueError):
            url_for(self.Person)
    def test_url_for_nonexistent(self):
        """Tests that attempting to get the URL for an unknown model yields an
        error.

        """
        with self.assertRaises(ValueError):
            url_for(self.Person)
 def test_url_for(self):
     manager = APIManager(self.flaskapp, session=self.session)
     manager.create_api(self.Person, collection_name='people')
     manager.create_api(self.Computer, collection_name='computers')
     with self.flaskapp.app_context():
         url = url_for(self.Computer)
         assert url.endswith('/api/computers')
         assert url_for(self.Person).endswith('/api/people')
         assert url_for(self.Person, instid=1).endswith('/api/people/1')
         url = url_for(self.Person, instid=1, relationname='computers')
         assert url.endswith('/api/people/1/computers')
         url = url_for(self.Person, instid=1, relationname='computers',
                       relationinstid=2)
         assert url.endswith('/api/people/1/computers/2')
Example #4
0
 def test_url_for(self):
     """Tests the global :func:`flask.ext.restless.url_for` function."""
     self.manager.create_api(self.Person, collection_name='people')
     self.manager.create_api(self.Article, collection_name='articles')
     with self.flaskapp.test_request_context():
         url1 = url_for(self.Person)
         url2 = url_for(self.Person, resource_id=1)
         url3 = url_for(self.Person, resource_id=1,
                        relation_name='articles')
         url4 = url_for(self.Person, resource_id=1,
                        relation_name='articles', related_resource_id=2)
         assert url1.endswith('/api/people')
         assert url2.endswith('/api/people/1')
         assert url3.endswith('/api/people/1/articles')
         assert url4.endswith('/api/people/1/articles/2')
Example #5
0
 def test_url_for(self):
     """Tests the global :func:`flask.ext.restless.url_for` function."""
     self.manager.create_api(self.Person, collection_name='people')
     self.manager.create_api(self.Article, collection_name='articles')
     with self.flaskapp.test_request_context():
         url1 = url_for(self.Person)
         url2 = url_for(self.Person, resource_id=1)
         url3 = url_for(self.Person, resource_id=1,
                        relation_name='articles')
         url4 = url_for(self.Person, resource_id=1,
                        relation_name='articles', related_resource_id=2)
         assert url1.endswith('/api/people')
         assert url2.endswith('/api/people/1')
         assert url3.endswith('/api/people/1/articles')
         assert url4.endswith('/api/people/1/articles/2')
Example #6
0
    def test_url_for_nonexistent(self):
        """Tests that attempting to get the URL for an unknown model yields an
        error.

        """
        url_for(self.Person)
Example #7
0
    def test_url_for_nonexistent(self):
        """Tests that attempting to get the URL for an unknown model yields an
        error.

        """
        url_for(self.Person)