Python AngularAppPortalRootTraverser Example

Introduction

The python angularappportalroottraverser example is extracted from the most popular open source projects, you can refer to the following example for usage.

Programming language: Python

Namespace/package name: ploneappangularjstraversal

Example#1
File: test_traversal.pyProject: jean/plone.app.angularjs

 def test_api_overview(self):
     self.request.URL = 'http://nohost/plone/++api++v1/'
     directlyProvides(self.request, IAPIRequest)
     traversal = AngularAppPortalRootTraverser(self.portal, self.request)
     view = traversal.publishTraverse(
         self.request,
         ""
     )
     self.assertTrue(
         "<h1>REST API</h1>" in view()
     )

Example#2
File: test_traversal.pyProject: jean/plone.app.angularjs

 def test_api_non_existing_method(self):
     self.request.URL = 'http://nohost/plone/++api++v1/'
     directlyProvides(self.request, IAPIRequest)
     traversal = AngularAppPortalRootTraverser(self.portal, self.request)
     view = traversal.publishTraverse(
         self.request,
         "non_existing_api_method"
     )
     self.assertEqual(
         json.loads(view)['message'],
         "API method 'non_existing_api_method' not found."
     )

Example#3
File: test_traversal.pyProject: jean/plone.app.angularjs

 def test_front_page_returns_angular_app(self):
     self.request.URL = 'http://nohost/plone/front-page'
     traversal = AngularAppPortalRootTraverser(self.portal, self.request)
     view = traversal.publishTraverse(self.request, "front-page")
     self.assertTrue('ng-app' in view)

Example#4
File: test_traversal.pyProject: jean/plone.app.angularjs

 def test_api_top_navigation(self):
     self.request.URL = 'http://nohost/plone/++api++v1/'
     directlyProvides(self.request, IAPIRequest)
     traversal = AngularAppPortalRootTraverser(self.portal, self.request)
     view = traversal.publishTraverse(self.request, "top_navigation")
     self.assertEqual(json.loads(view()), [])

Example#5
File: test_traversal.pyProject: jean/plone.app.angularjs

 def test_portal_root_folder_listing_returns_angular_app(self):
     self.request.URL = 'http://nohost/plone/folder_listing'
     traversal = AngularAppPortalRootTraverser(self.portal, self.request)
     view = traversal.publishTraverse(self.request, "folder_listing")
     self.assertTrue('ng-app' in view)