Exemplo n.º 1
0
    def test_closeAccount(self):
        acc = duckbill.Account(account="ftempy")
        acc.subscriptions << duckbill.Subscription()
        acc = self.clerk.store(acc)
        accID = acc.ID

        assert acc.status == 'active'

        REQ = weblib.RequestBuilder().build(method="POST",
                                            querystring="",
                                            form={
                                                'action': 'close_account',
                                                'reason': 'xxx',
                                                'ID': str(accID)
                                            },
                                            cookie={},
                                            content=None)

        app = duckbill.FrontEndApp(self.clerk, REQ)
        self.assertRaises(weblib.Redirect, app.act)

        self.assertEquals('closed', acc.status, 'dig nibbit?')

        all = self.clerk.match(duckbill.Account)
        assert len(all) == 1, all

        acc = all[0]
        self.assertEquals('closed', acc.status, 'dag nabbit!')
        self.assertEquals('closed', acc.subscriptions[0].status)
Exemplo n.º 2
0
 def setUp(self):
     self.myReq = weblib.RequestBuilder().build(method="GET",
                                                querystring="",
                                                path="/",
                                                form={},
                                                cookie={},
                                                content={})
     self.myRes = weblib.Response()
     self.sess = Sess(InMemorySessPool(), self.myReq, self.myRes)
Exemplo n.º 3
0
 def test_createAccount(self):
     # test to expose a bug... all this SHOULD do is show a form..
     #@TODO: will need to clean this up once weblib refactoring is done
     REQ = weblib.RequestBuilder().build(
         method="GET",
         querystring="action=create&what=account",
         form={},
         cookie={},
         content=None)
     app = duckbill.FrontEndApp(self.clerk, REQ)
     app.act()
Exemplo n.º 4
0
    def __init__(self, script=None, request=None, path="."):
        """
        script should be a string with actual code.
        """
        self.script = script
        self.request = request or weblib.RequestBuilder().build()
        self.response = self.makeResponse()

        self.result = None
        self.error = None
        self.path = path
        self.makeGlobals()

        # stuff to do at exit:
        self._exitstuff = []
        self.setPathInfo()
Exemplo n.º 5
0
 def test_login_valid(self):
     """
     Valid login should have no side effects.
     """
     req = weblib.RequestBuilder().build(querystring="auth_check_flag=1",
                                         path="/",
                                         form={
                                             "auth_username": "******",
                                             "auth_password": "******"
                                         })
     sess = Sess(InMemorySessPool(), req, self.myRes)
     try:
         auth = Auth(sess, {"username": "******"})
         auth.check()
         gotExit = 0
     except Finished:
         gotExit = 1
     assert self.myRes.buffer == "", \
            "valid login shouldn't output anything! [vs '%s']" \
            % self.myRes.buffer
     assert not gotExit, \
            "valid login still threw Finished"
Exemplo n.º 6
0
 def test_login_invalid(self):
     """
     Invalid login should show error, display form, and raise Finished.
     """
     req = weblib.RequestBuilder().build(querystring="auth_check_flag=1",
                                         path="/",
                                         form={
                                             "auth_username":
                                             "******",
                                             "auth_password":
                                             "******"
                                         })
     sess = Sess(InMemorySessPool(), req, self.myRes)
     try:
         auth = Auth(sess, {'username': '******'})
         auth.check()
         gotExit = 0
     except Finished:
         gotExit = 1
     assert gotExit, \
            "invalid login didn't get Finished"
     assert string.find(self.myRes.buffer, auth.LOGINFAILED) > -1, \
            "invalid login doesn't give LOGINFAILED!"
Exemplo n.º 7
0
 def setUp(self, sid=None):
     self.builder = weblib.RequestBuilder()
     self.pool = SessPool.InMemorySessPool({})
     self.sess = weblib.Sess(self.pool, self.builder.build(),
                             weblib.Response())
     self.sess.start(sid)
Exemplo n.º 8
0
 def setUp(self):
     self.c = arlo.MockClerk(DBMAP)
     self.r = weblib.RequestBuilder().build()
     self.p = PlanApp(self.c, self.r)