Ejemplo n.º 1
0
 def _build_context(self, **kw):
     from sqlalchemy.orm import object_session
     from euphorie.client.api.actionplans import RiskActionPlans
     from euphorie.client.model import Risk
     from euphorie.client.api.tests.test_risk import _setup_session
     self.loginAsPortalOwner()
     (account, survey, survey_session) = _setup_session(self.portal)
     risk = object_session(survey_session).query(Risk).one()
     return RiskActionPlans('actionplans', None, risk)
Ejemplo n.º 2
0
 def _build_context(self, **kw):
     from sqlalchemy.orm import object_session
     from euphorie.client.api.actionplans import RiskActionPlans
     from euphorie.client.model import Risk
     from euphorie.client.api.tests.test_risk import _setup_session
     self.loginAsPortalOwner()
     (account, survey, survey_session) = _setup_session(self.portal)
     risk = object_session(survey_session).query(Risk).one()
     return RiskActionPlans('actionplans', None, risk)
Ejemplo n.º 3
0
    def test_get(self):
        import datetime
        import json
        from sqlalchemy.orm import object_session
        from euphorie.client.model import Risk
        from euphorie.client.model import ActionPlan
        from euphorie.client.api.authentication import generate_token
        from euphorie.client.api.tests.test_risk import _setup_session

        self.loginAsPortalOwner()
        (account, survey, survey_session) = _setup_session(self.portal)
        risk = object_session(survey_session).query(Risk).one()
        risk.action_plans.append(ActionPlan(action_plan=u"This is the plan", planning_start=datetime.date(2012, 6, 3)))
        browser = Browser()
        browser.addHeader("X-Euphorie-Token", generate_token(account))
        browser.open("http://nohost/plone/client/api/users/1/" "sessions/1/1/1/actionplans/1")
        self.assertEqual(browser.headers["Content-Type"], "application/json")
        response = json.loads(browser.contents)
        self.assertEqual(response["plan"], u"This is the plan")
Ejemplo n.º 4
0
 def test_get(self):
     import datetime
     import json
     from sqlalchemy.orm import object_session
     from euphorie.client.model import Risk
     from euphorie.client.model import ActionPlan
     from euphorie.client.api.authentication import generate_token
     from euphorie.client.api.tests.test_risk import _setup_session
     self.loginAsPortalOwner()
     (account, survey, survey_session) = _setup_session(self.portal)
     risk = object_session(survey_session).query(Risk).one()
     risk.action_plans.append(
         ActionPlan(action_plan=u'This is the plan',
                    planning_start=datetime.date(2012, 6, 3)))
     browser = Browser()
     browser.addHeader('X-Euphorie-Token', generate_token(account))
     browser.open('http://nohost/plone/client/api/users/1/'
                  'sessions/1/1/1/actionplans')
     self.assertEqual(browser.headers['Content-Type'], 'application/json')
     response = json.loads(browser.contents)
     self.assertTrue('action-plans' in response)