def test_url_for(self):
        # Make two documents
        doc1 = NamedDocument(name=u'document1', title=u"Document 1")
        self.session.add(doc1)
        c1 = Container()  # Gets an autoincrementing id starting from 1
        self.session.add(c1)
        doc2 = ScopedNamedDocument(container=c1, name=u'document2', title=u"Document 2")
        self.session.add(doc2)
        self.session.commit()

        # Confirm first returns the correct paths
        self.assertEqual(doc1.url_for(), '/document1')
        self.assertEqual(doc1.url_for('view'), '/document1')
        self.assertEqual(doc1.url_for('edit'), '/document1/edit')
        # Test callable parameters
        self.assertEqual(doc1.url_for('upper'), '/DOCUMENT1/upper')
        # Insist on changing one of the parameters
        self.assertEqual(doc1.url_for('edit', doc=doc1.name.upper()), '/DOCUMENT1/edit')
        # Confirm second returns the correct paths
        self.assertEqual(doc2.url_for(), '/1/document2')
        self.assertEqual(doc2.url_for('view'), '/1/document2')
        # Test _external flag
        self.assertEqual(doc2.url_for('edit'), 'http://localhost/1/document2/edit')
        self.assertEqual(doc2.url_for('edit', _external=False), '/1/document2/edit')
        self.assertEqual(doc2.url_for('edit', _external=True), 'http://localhost/1/document2/edit')
Test that is_url_for declarations are saved and used by the url_for method.
dataset/ETHPy150Open hasgeek/coaster/tests/test_url_for.py/TestUrlFor.test_url_for