Exemple #1
0
    def test_multiple_student_dashboard(self, client):
        """A user with multiple students gets redirected to dashboard."""
        rel = factories.RelationshipFactory(to_profile__name="Student One")
        factories.RelationshipFactory(
            from_profile=rel.elder, to_profile__name="Student Two")
        response = client.get(self.url, user=rel.elder.user, status=302)

        assert response['Location'] == location(reverse('all_students_dash'))
Exemple #2
0
    def test_logout_redirect(self, client):
        """Successful logout POST redirects to the home page."""
        profile = factories.ProfileFactory.create()

        url = reverse('no_students')

        form = client.get(url, user=profile.user).forms['logoutform']
        res = form.submit(status=302)

        assert res['Location'] == utils.location(reverse('home'))
    def test_logout_redirect(self, client):
        """Successful logout POST redirects to the home page."""
        profile = factories.ProfileFactory.create()

        url = reverse('no_students')

        form = client.get(url, user=profile.user).forms['logoutform']
        res = form.submit(status=302)

        assert res['Location'] == utils.location(reverse('home'))
Exemple #4
0
    def test_login(self, client):
        """Successful login redirects."""
        factories.ProfileFactory.create(
            user__email='*****@*****.**', user__password='******')

        form = client.get(self.url).forms['loginform']
        form['username'] = '******'
        form['password'] = '******'
        res = form.submit(status=302)

        assert res['Location'] == utils.location(reverse('home'))
    def test_login(self, client):
        """Successful login redirects."""
        factories.ProfileFactory.create(user__email='*****@*****.**',
                                        user__password='******')

        form = client.get(self.url).forms['loginform']
        form['username'] = '******'
        form['password'] = '******'
        res = form.submit(status=302)

        assert res['Location'] == utils.location(reverse('home'))
Exemple #6
0
    def test_register(self, client):
        """Get logged in and redirected to home after registering."""
        school = factories.SchoolFactory.create()
        form = client.get(self.url).forms['register-form']
        form['name'] = 'Some Body'
        form['email'] = '*****@*****.**'
        form['password'] = '******'
        form['password_confirm'] = 'sekrit123'
        form['role'] = 'Test User'
        form['country_code'] = 'us'
        form['school'] = str(school.id)
        res = form.submit(status=302)

        assert res['Location'] == utils.location(reverse('add_student'))

        res.follow(status=200)
    def test_register(self, client):
        """Get logged in and redirected to home after registering."""
        school = factories.SchoolFactory.create()
        form = client.get(self.url).forms['register-form']
        form['name'] = 'Some Body'
        form['email'] = '*****@*****.**'
        form['phone'] = '321-654-9876'
        form['password'] = '******'
        form['password_confirm'] = 'sekrit123'
        form['role'] = 'Test User'
        form['country_code'] = 'us'
        form['school'] = str(school.id)
        form['terms_confirm'] = True
        res = form.submit(status=302)

        assert res['Location'] == utils.location(reverse('add_student'))

        res.follow(status=200)
Exemple #8
0
    def test_good_captcha(self, client):
        """Good value for captcha allows login."""
        factories.ProfileFactory.create(
            user__email='*****@*****.**', user__password='******')

        session_data = {}

        with utils.patch_session(session_data):
            res = client.get(self.url)
            for i in range(6):
                res = res.forms['loginform'].submit()

            form = res.forms['loginform']
            answer = session_data['auth_captcha_answer']
            form['captcha'] = answer
            form['username'] = '******'
            form['password'] = '******'
            res = form.submit(status=302)

        assert res['Location'] == utils.location(reverse('home'))
    def test_good_captcha(self, client):
        """Good value for captcha allows login."""
        factories.ProfileFactory.create(user__email='*****@*****.**',
                                        user__password='******')

        session_data = {}

        with utils.patch_session(session_data):
            res = client.get(self.url)
            for i in range(6):
                res = res.forms['loginform'].submit()

            form = res.forms['loginform']
            answer = session_data['auth_captcha_answer']
            form['captcha'] = answer
            form['username'] = '******'
            form['password'] = '******'
            res = form.submit(status=302)

        assert res['Location'] == utils.location(reverse('home'))
Exemple #10
0
    def test_login_required(self, client):
        """Redirects to signup if user is unauthenticated."""
        res = client.get(self.url, status=302)

        assert res['Location'] == utils.location(
            reverse('login') + '?next=' + self.url)
    def test_login_required(self, client):
        """Redirects to signup if user is unauthenticated."""
        res = client.get(self.url, status=302)

        assert res['Location'] == utils.location(
            reverse('login') + '?next=' + self.url)
Exemple #12
0
    def test_redirect_to_no_students(self, client):
        """Redirects to no-students if non-staff user has no students."""
        profile = factories.ProfileFactory.create(school_staff=False)
        res = client.get(self.url, user=profile.user, status=302)

        assert res['Location'] == location(reverse('no_students'))
Exemple #13
0
    def test_redirect_to_add_group(self, client):
        """Redirects to add-student if staff user has no students."""
        profile = factories.ProfileFactory.create(school_staff=True)
        res = client.get(self.url, user=profile.user, status=302)

        assert res['Location'] == location(reverse('add_student'))