예제 #1
0
    def setup_invites(self, is_approved=False):
        approver = self.users[0]
        conversation_id = self.conversation.conversation_id
        invite = model.Invitation(joining_user_id=approver.user_id,
                                  approver_user_id=approver.user_id,
                                  is_approved=True)
        model.db.session.add(invite)
        joiner = model.User(conversation_id=conversation_id,
                            name='bob',
                            public_key='')
        model.db.session.add(joiner)
        model.db.session.commit()
        joiner_user_id = joiner.user_id

        invite = model.Invitation(joining_user_id=joiner_user_id,
                                  approver_user_id=approver.user_id,
                                  is_approved=is_approved)
        model.db.session.add(invite)
        model.db.session.commit()
        return (approver.user_id, joiner_user_id, conversation_id,
                invite.invite_id)
예제 #2
0
    def testIsNotApproved(self):
        """Tests is approved returns False when a user is not approved."""
        user = model.User(conversation_id=self.conversation.conversation_id,
                          name='bob',
                          public_key='')
        model.db.session.add(user)
        model.db.session.commit()

        invite = model.Invitation(joining_user_id=user.user_id,
                                  approver_user_id=self.user.user_id)

        model.db.session.add(invite)
        model.db.session.commit()

        self.assertFalse(user.is_approved())
예제 #3
0
    def testIsNotRejectedIsRejectedNone(self):
        """is_rejected returns False when invitation.is_approved is None."""
        u = model.User(name='bob',
                       public_key='',
                       conversation_id=self.conversation.conversation_id)
        model.db.session.add(u)
        model.db.session.commit()
        user = u

        invite = model.Invitation(joining_user_id=user.user_id,
                                  approver_user_id=self.user.user_id)
        model.db.session.add(invite)
        model.db.session.commit()

        self.assertFalse(user.is_rejected())
예제 #4
0
    def testIsRejected(self):
        """Tests a user that is rejected."""
        u = model.User(name='bob',
                       public_key='',
                       conversation_id=self.conversation.conversation_id)
        model.db.session.add(u)
        model.db.session.commit()
        user = u

        invite = model.Invitation(joining_user_id=user.user_id,
                                  approver_user_id=self.user.user_id,
                                  is_approved=False)
        model.db.session.add(invite)
        model.db.session.commit()

        self.assertTrue(u.is_rejected())
예제 #5
0
    def setUp(self):
        """Setup database tables."""
        model.db.create_all()

        self.conversation = model.Conversation(conversation_code='foo')
        model.db.session.add(self.conversation)
        model.db.session.commit()

        user = model.User(conversation_id=self.conversation.conversation_id,
                          name='alice',
                          public_key='')
        model.db.session.add(user)
        model.db.session.commit()
        self.user = user

        invitation = model.Invitation(joining_user_id=user.user_id,
                                      approver_user_id=user.user_id)
        model.db.session.add(invitation)
        model.db.session.commit()
        self.invite = invitation