示例#1
0
    def setup_method(self, m):
        self.cx = uts.resetDB()
        self.cu = self.cx.cursor()

        self.srv = core.Service(uts.url())
        self.srv.startService()
        return
示例#2
0
def prepare(debug):
    """Bind together the webserver components.

    Args:
      debug: bool, if True run in debug mode
    
    Returns:
      service.Application
    """
    application = service.Application("mes-souhaits")

    if debug:
        url = 'http://127.0.0.1:%d' % PORT
    else:
        url = 'http://mes-souhaits.net'

    srv = core.Service(url, debug=debug)
    srv.setServiceParent(application)

    root = pages.RootPage(srv)
    root.putChild('vhost', vhost.VHostMonsterResource())

    site = appserver.NevowSite(root)

    server = internet.TCPServer(PORT, site)  # pylint: disable-msg=E1101
    server.setServiceParent(application)

    return application
示例#3
0
    def test_SendAgain(self):
        """ It is possible to ask for a second email, possibly
        changing the email address in the process. """

        self.u.open()
        self.u.siteLogin('*****@*****.**')
        uts.resetMail()

        self.u.siteLogin('*****@*****.**')
        self.u.openChallenge()

        self.srv = core.Service(uts.url())
        self.srv.startService()

        assert not self.srv.getUserByEmail('*****@*****.**')
        assert self.srv.getUserByEmail('*****@*****.**')
示例#4
0
    def setup_method(self, m):
        # Our initial state is a session with a user owning a list
        self.srv = core.Service(uts.url())
        self.srv.startService()

        self.cx = uts.resetDB()
        self.cu = self.cx.cursor()

        uts.resetMail()

        self.a_user, self.a_list = self.a.makeUserAndList(self.srv, 'a')
        self.b_user, self.b_list = self.b.makeUserAndList(self.srv, 'b')

        self.b.open('/liste-b')

        self.b.createItem(title='A test',
                          description='blah...',
                          url='http://www/')

        self.b_item = self.srv.itemsForList(self.b_list)
示例#5
0
    def testInviteUnknownPerson(self):
        """ Send an invitation to someone that never used the site."""

        srv = core.Service(uts.url())
        srv.startService()

        list_id = srv.getListByURL(self.u_list)

        self.u.inviteFriend('me', '*****@*****.**', 'youyou', [list_id])
        o = uts.SouhaitUser()
        try:
            o.openChallenge()
        finally:
            o.stop()

        # the person should have a home page with a link to a's list
        u = srv.getUserByEmail('*****@*****.**')

        # We only keep the list info, not the freshness
        friends = [l[0] for l in srv.getFriendLists(u)]
        assert friends == [list_id]
示例#6
0
    def testListMerging(self):
        # user b has a wish in his list
        self.u.open('/' + self.u_list)
        self.u.createItem(title='A test',
                          description='blah...',
                          url='http://www/')

        # user a logs in and visits list b
        a = uts.SouhaitUser()
        a.open()
        a.siteLogin('*****@*****.**')
        a.openChallenge()
        a.open('/' + self.u_list)

        srv = core.Service(uts.url())
        srv.startService()

        a_id = srv.getUserByEmail('*****@*****.**')

        try:
            self.cu.execute('SELECT COUNT (*) FROM friend WHERE user = ?',
                            (a_id.id, ))
            assert self.cu.fetchone()[0] == 1

            # a logs out, comes back to the list of b, logs in, visits the
            # page and confirms her identity after that.
            a.siteLogout()
            a.siteLogin('*****@*****.**')
            a.openChallenge()

            # we should not have a duplicate
            self.cu.execute('SELECT COUNT (*) FROM friend WHERE user = ?',
                            (a_id.id, ))
            assert self.cu.fetchone()[0] == 1

        finally:
            a.stop()
示例#7
0
 def setup_method(self, method):
     uts.resetDB()
     uts.resetMail()
     self.db = core.Service('http://localhost:7707', debug=True)
     self.db.startService()