Esempio n. 1
0
    def test_ForceUserToProvideListInfo(self):
        """ Check that the email and the list name are completed """

        self.u.open()
        self.u.createList('Ma nouvelle liste')

        assert self.u.location() == uts.url('/newlist')

        # just add the email, as the listname should still be here
        self.u.createList(None, '*****@*****.**')
        assert self.u.location() == uts.url('/ma-nouvelle-liste')
Esempio n. 2
0
    def test_CreateListAsGuest(self):
        """ Create a list as a new  user. You then get a mail and are pre-logged """

        self.u.open()
        self.u.createList('Ma nouvelle liste', '*****@*****.**')

        # the user received a nice mail to get logged, while he is
        # directed to the list's page.
        assert self.u.location() == uts.url('/ma-nouvelle-liste')

        # from that point, there is a challenge, a user and a session
        # in the system
        self.cu.execute('SELECT COUNT (*) FROM session')
        assert self.cu.fetchone()[0] == 1

        self.cu.execute('SELECT key FROM user')
        r = self.cu.fetchall()
        assert len(r) == 1

        user, = r[0]

        self.cu.execute('SELECT COUNT (*) FROM wishlist')
        assert self.cu.fetchone()[0] == 1

        # when the user follows the link, the challenge is accepted,
        # and the user's email is validated
        self.u.openChallenge()

        self.cu.execute('SELECT email FROM user WHERE key = ?', (user, ))
        address = self.cu.fetchone()[0]

        assert address == '*****@*****.**'

        self.cu.execute('SELECT COUNT (*) FROM wishlist')
        assert self.cu.fetchone()[0] == 1
Esempio n. 3
0
    def testUnknownCoeditor(self):
        """Refuse to set an unknown user as coeditor."""
        self.a.open('/liste-a/edit')
        self.a.b.type('coEditors', '*****@*****.**')
        self.a.Submit('desc')

        assert self.a.location() == uts.url('/liste-a/edit')
Esempio n. 4
0
    def testReserveSimple(self):

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

        # Make a reservation
        self.a.Reserve()

        # We should be on the same page
        assert self.a.location() == uts.url('/liste-b')

        # ...and a has a reservation
        r = self.srv.getUserReservations(self.a_user)
        assert len(r) == 1

        # but now, the item is no more to be reserved
        try:
            self.a.Reserve()
            assert False, 'should not happen'
        except Exception:
            pass

        # on the other hand, it is in the "reserved" list
        self.a.open('/')
        self.a.Giveup()

        r = self.srv.getUserReservations(self.a_user)
        assert len(r) == 0
Esempio n. 5
0
    def testDetectMissingListInfo(self):
        """ For an logged user, it is necessary to provide a list name """

        self.u.open('/newlist')
        self.u.createList('')

        assert self.u.location() == uts.url('/newlist')
Esempio n. 6
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
Esempio n. 7
0
    def test_reject_invalid_email_in_list(self):
        self.u.open()
        self.u.createList('foo', 'a@b')  # missing tld

        # we're still on the new list page
        assert self.u.location() == uts.url('/newlist')
        self.cu.execute('SELECT COUNT (*) FROM wishlist')
        assert self.cu.fetchone()[0] == 0
Esempio n. 8
0
    def test_reject_invalid_login(self):
        self.u.open()
        self.u.siteLogin('a@b')  # missing tld

        # we're still on the login page
        assert self.u.location() == uts.url('/login')
        self.cu.execute('SELECT COUNT (*) FROM challenge')
        assert self.cu.fetchone()[0] == 0
Esempio n. 9
0
    def testNoNeedForEmail(self):
        """ For an logged user, no need to provide an email """

        uts.resetMail()
        self.u.open('/newlist')
        self.u.createList('autre liste')

        assert self.u.location() == uts.url('/autre-liste')
        assert open('+mailbox').read() == ''
Esempio n. 10
0
    def testReserveAnonyme(self):
        """ To reserve an item as an anonymous user, you need to ask
        the identity of the user"""

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

        uts.resetMail()

        self.a.Reserve()
        assert self.a.location().startswith(uts.url('/login'))
Esempio n. 11
0
    def testReopenChallenge(self):
        self.a.inviteFriend('me', '*****@*****.**', 'youyou', [self.a_list])

        challenge = self.b.openChallenge()

        # if someone else opens this page, he/she gets logged in
        o = uts.SouhaitUser()
        try:
            o.open(raw=challenge)
            assert o.location() == uts.url('/')
        finally:
            o.stop()
Esempio n. 12
0
    def testDeleteItem(self):

        self.u.open('/ma-nouvelle-liste')

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

        assert self.u.location() == uts.url('/ma-nouvelle-liste')

        self.cu.execute('SELECT title, description, url FROM item')
        assert len(self.cu.fetchall()) == 0
Esempio n. 13
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('*****@*****.**')
Esempio n. 14
0
    def test_BasicSessions(self):
        # Hitting the front page creates no session
        self.u.open()
        self.cu.execute('SELECT COUNT(*) FROM session')
        assert self.cu.fetchone()[0] == 0

        # Try to use the login button
        self.u.open()
        self.u.siteLogin('*****@*****.**')
        assert self.u.location() == uts.url()
        self.u.openChallenge()

        # try to logout immediately after
        self.u.siteLogout()
        self.cu.execute('SELECT * FROM session')
        r = self.cu.fetchall()
        assert len(r) == 0
Esempio n. 15
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)
Esempio n. 16
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]
Esempio n. 17
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()
Esempio n. 18
0
    def test_DetectMissingListInfo(self):
        """ For an anonymous user, it is necessary to provide both email and list name """

        self.u.open()
        self.u.createList(None, '*****@*****.**')
        assert self.u.location() == uts.url('/newlist')