コード例 #1
0
    def test_dao_mentorship_request_is_not_in_pending_state(self):
        DAO = MentorshipRelationDAO()

        self.mentorship_relation.state = MentorshipRelationState.ACCEPTED
        db.session.add(self.mentorship_relation)
        db.session.commit()

        result = DAO.accept_request(self.second_user.id,
                                    self.mentorship_relation.id)
        self.assertEqual((messages.NOT_PENDING_STATE_RELATION, 400), result)

        self.mentorship_relation.state = MentorshipRelationState.COMPLETED
        db.session.add(self.mentorship_relation)
        db.session.commit()

        result = DAO.accept_request(self.second_user.id,
                                    self.mentorship_relation.id)
        self.assertEqual((messages.NOT_PENDING_STATE_RELATION, 400), result)

        self.mentorship_relation.state = MentorshipRelationState.CANCELLED
        db.session.add(self.mentorship_relation)
        db.session.commit()

        result = DAO.accept_request(self.second_user.id,
                                    self.mentorship_relation.id)
        self.assertEqual((messages.NOT_PENDING_STATE_RELATION, 400), result)

        self.mentorship_relation.state = MentorshipRelationState.REJECTED
        db.session.add(self.mentorship_relation)
        db.session.commit()

        result = DAO.accept_request(self.second_user.id,
                                    self.mentorship_relation.id)
        self.assertEqual((messages.NOT_PENDING_STATE_RELATION, 400), result)
コード例 #2
0
    def test_dao_sender_does_not_exist_mentorship_request(self):
        DAO = MentorshipRelationDAO()

        result = DAO.accept_request(123, self.mentorship_relation.id)

        self.assertEqual((messages.USER_DOES_NOT_EXIST, 404), result)
        self.assertEqual(MentorshipRelationState.PENDING,
                         self.mentorship_relation.state)
コード例 #3
0
    def test_dao_accept_non_existing_mentorship_request(self):
        DAO = MentorshipRelationDAO()

        result = DAO.accept_request(self.first_user.id, 123)

        self.assertEqual(
            (messages.MENTORSHIP_RELATION_REQUEST_DOES_NOT_EXIST, 404), result)
        self.assertEqual(MentorshipRelationState.PENDING,
                         self.mentorship_relation.state)
コード例 #4
0
    def test_dao_mentee_user_already_in_relationship(self):
        DAO = MentorshipRelationDAO()

        result = DAO.accept_request(self.second_user.id,
                                    self.mentorship_relation.id)

        self.assertEqual(
            (messages.MENTORSHIP_RELATION_WAS_ACCEPTED_SUCCESSFULLY, 200),
            result)
        self.assertEqual(MentorshipRelationState.ACCEPTED,
                         self.mentorship_relation.state)

        result3 = DAO.accept_request(self.third_user.id,
                                     self.mentorship_relation3.id)

        self.assertEqual((messages.MENTEE_ALREADY_IN_A_RELATION, 400), result3)
        self.assertEqual(MentorshipRelationState.PENDING,
                         self.mentorship_relation3.state)
コード例 #5
0
    def test_dao_requester_tries_to_accept_mentorship_request(self):
        DAO = MentorshipRelationDAO()

        result = DAO.accept_request(self.first_user.id,
                                    self.mentorship_relation.id)

        self.assertEqual((messages.CANT_ACCEPT_MENTOR_REQ_SENT_BY_USER, 400),
                         result)
        self.assertEqual(MentorshipRelationState.PENDING,
                         self.mentorship_relation.state)
コード例 #6
0
    def test_dao_receiver_accepts_mentorship_request(self):
        DAO = MentorshipRelationDAO()

        result = DAO.accept_request(self.second_user.id,
                                    self.mentorship_relation.id)

        self.assertEqual(
            (messages.MENTORSHIP_RELATION_WAS_ACCEPTED_SUCCESSFULLY, 200),
            result)
        self.assertEqual(MentorshipRelationState.ACCEPTED,
                         self.mentorship_relation.state)