Ejemplo n.º 1
0
    def test_verify_membership_payment(self):
        """Tests verifiy_membership_payment modifies user properly."""
        from acm_phoenix.users import constants as USER
        with self.client.session_transaction() as sess:
            user = User("Test User", "testu001", "*****@*****.**", "S", "CS",
                        "M", "test user", "testsig")
            db.session.add(user)
            db.session.commit()
            login_user(user)
            sess['user_id'] = user.id

        wepay_membership_response(current_user)

        # Bad key. Shouldn't modify user. Silently redirects to profile.
        response = self.client.get(url_for('users.verify_membership_payment',
                                           verification_key='randomkey'),
                                   follow_redirects=True)
        self.assert200(response)
        self.assertTemplateUsed('users/profile.html')
        self.assertEquals(current_user.membership_status, USER.IN_PROGRESS)
        self.assertIsNone(current_user.membership_paid_on)

        key = current_user.wepay_verification
        response = self.client.get(url_for('users.verify_membership_payment',
                                           verification_key=key),
                                   follow_redirects=True)
        self.assert200(response)
        self.assertTemplateUsed('users/profile.html')
        self.assertEquals(current_user.member_since,
                          current_user.membership_paid_on)

        self.assertEquals(user.membership_status, USER.PAID)

        logout_user()
Ejemplo n.º 2
0
    def test_wepay_membership_response(self):
        """Tests that wepay_membership_response gives a valid response and
        modifies the user object passed in."""
        user = User("Test User", "testu001", "*****@*****.**", "S", "CS",
                    "M", "test user", "testsig")

        self.assertIsNone(user.wepay_verification)
        response = wepay_membership_response(user)
        self.assertIsNotNone(user.wepay_verification)
        self.assertIn('wepay.com', response['checkout_uri'])