Merge pull request #266 from MITx/cpennington/fix_tests
Cpennington/fix tests
This commit is contained in:
@@ -30,6 +30,7 @@ class AuthTestCase(TestCase):
|
||||
self.email = 'a@b.com'
|
||||
self.pw = 'xyz'
|
||||
self.username = 'testuser'
|
||||
self.client = Client()
|
||||
|
||||
def check_page_get(self, url, expected):
|
||||
resp = self.client.get(url)
|
||||
@@ -63,7 +64,8 @@ class AuthTestCase(TestCase):
|
||||
'language' : 'Franglish',
|
||||
'name' : 'Fred Weasley',
|
||||
'terms_of_service' : 'true',
|
||||
'honor_code' : 'true'})
|
||||
'honor_code' : 'true',
|
||||
})
|
||||
return resp
|
||||
|
||||
def create_account(self, username, email, pw):
|
||||
@@ -121,7 +123,7 @@ class AuthTestCase(TestCase):
|
||||
resp = self._login(self.email, self.pw)
|
||||
data = parse_json(resp)
|
||||
self.assertFalse(data['success'])
|
||||
|
||||
|
||||
self.activate_user(self.email)
|
||||
|
||||
# Now login should work
|
||||
@@ -144,6 +146,9 @@ class AuthTestCase(TestCase):
|
||||
# need an activated user
|
||||
self.test_create_account()
|
||||
|
||||
# Create a new session
|
||||
self.client = Client()
|
||||
|
||||
# Not logged in. Should redirect to login.
|
||||
print 'Not logged in'
|
||||
for page in auth_pages:
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
from util.json_request import expect_json
|
||||
import json
|
||||
|
||||
from django.http import HttpResponse
|
||||
from django.http import HttpResponse, Http404
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.context_processors import csrf
|
||||
from django_future.csrf import ensure_csrf_cookie
|
||||
from django.core.urlresolvers import reverse
|
||||
from fs.osfs import OSFS
|
||||
|
||||
from xmodule.modulestore import Location
|
||||
from github_sync import export_to_github
|
||||
@@ -14,6 +13,7 @@ from github_sync import export_to_github
|
||||
from mitxmako.shortcuts import render_to_response
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
|
||||
# ==== Public views ==================================================
|
||||
|
||||
@ensure_csrf_cookie
|
||||
@@ -22,7 +22,8 @@ def signup(request):
|
||||
Display the signup form.
|
||||
"""
|
||||
csrf_token = csrf(request)['csrf_token']
|
||||
return render_to_response('signup.html', {'csrf': csrf_token })
|
||||
return render_to_response('signup.html', {'csrf': csrf_token})
|
||||
|
||||
|
||||
@ensure_csrf_cookie
|
||||
def login_page(request):
|
||||
@@ -30,8 +31,9 @@ def login_page(request):
|
||||
Display the login form.
|
||||
"""
|
||||
csrf_token = csrf(request)['csrf_token']
|
||||
return render_to_response('login.html', {'csrf': csrf_token })
|
||||
|
||||
return render_to_response('login.html', {'csrf': csrf_token})
|
||||
|
||||
|
||||
# ==== Views for any logged-in user ==================================
|
||||
|
||||
@login_required
|
||||
@@ -47,6 +49,7 @@ def index(request):
|
||||
for course in courses]
|
||||
})
|
||||
|
||||
|
||||
# ==== Views with per-item permissions================================
|
||||
|
||||
def has_access(user, location):
|
||||
@@ -54,18 +57,20 @@ def has_access(user, location):
|
||||
# TODO (vshnayder): actually check perms
|
||||
return user.is_active and user.is_authenticated
|
||||
|
||||
|
||||
@login_required
|
||||
@ensure_csrf_cookie
|
||||
def course_index(request, org, course, name):
|
||||
location = ['i4x', org, course, 'course', name]
|
||||
if not has_access(request.user, location):
|
||||
raise Http404 # TODO (vshnayder): better error
|
||||
|
||||
|
||||
# TODO (cpennington): These need to be read in from the active user
|
||||
course = modulestore().get_item(location)
|
||||
weeks = course.get_children()
|
||||
return render_to_response('course_index.html', {'weeks': weeks})
|
||||
|
||||
|
||||
@login_required
|
||||
def edit_item(request):
|
||||
# TODO (vshnayder): change name from id to location in coffee+html as well.
|
||||
@@ -73,7 +78,7 @@ def edit_item(request):
|
||||
print item_location, request.GET
|
||||
if not has_access(request.user, item_location):
|
||||
raise Http404 # TODO (vshnayder): better error
|
||||
|
||||
|
||||
item = modulestore().get_item(item_location)
|
||||
return render_to_response('unit.html', {
|
||||
'contents': item.get_html(),
|
||||
@@ -98,6 +103,7 @@ def user_author_string(user):
|
||||
last=l,
|
||||
email=user.email)
|
||||
|
||||
|
||||
@login_required
|
||||
@expect_json
|
||||
def save_item(request):
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
Someone, hopefully you, signed up for an account for edX's on-line
|
||||
offering of "${ course_title}" using this email address. If it was
|
||||
you, and you'd like to activate and use your account, copy and paste
|
||||
this address into your web browser's address bar:
|
||||
Thank you for signing up for edX! To activate your account,
|
||||
please copy and paste this address into your web browser's
|
||||
address bar:
|
||||
|
||||
% if is_secure:
|
||||
https://${ site }/activate/${ key }
|
||||
% else:
|
||||
http://edx4edx.mitx.mit.edu/activate/${ key }
|
||||
http://${ site }/activate/${ key }
|
||||
% endif
|
||||
|
||||
If you didn't request this, you don't need to do anything; you won't
|
||||
|
||||
@@ -1 +1 @@
|
||||
Your account for edX's on-line ${course_title} course
|
||||
Your account for edX
|
||||
|
||||
30
cms/templates/registration/activation_complete.html
Normal file
30
cms/templates/registration/activation_complete.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<%! from django.core.urlresolvers import reverse %>
|
||||
<%inherit file="../base.html" />
|
||||
|
||||
<%namespace name='static' file='../static_content.html'/>
|
||||
|
||||
<section class="container activation">
|
||||
|
||||
<section class="message">
|
||||
%if not already_active:
|
||||
<h1 class="valid">Activation Complete!</h1>
|
||||
%else:
|
||||
<h1>Account already active!</h1>
|
||||
%endif
|
||||
<hr class="horizontal-divider">
|
||||
|
||||
<p>
|
||||
%if not already_active:
|
||||
Thanks for activating your account.
|
||||
%else:
|
||||
This account has already been activated.
|
||||
%endif
|
||||
|
||||
%if user_logged_in:
|
||||
Visit your <a href="${reverse('dashboard')}">dashboard</a> to see your courses.
|
||||
%else:
|
||||
You can now <a href="#login-modal" rel="leanModal">login</a>.
|
||||
%endif
|
||||
</p>
|
||||
</section>
|
||||
</section>
|
||||
@@ -307,14 +307,14 @@ def create_account(request, post_override=None):
|
||||
|
||||
up = UserProfile(user=u)
|
||||
up.name = post_vars['name']
|
||||
up.level_of_education = post_vars['level_of_education']
|
||||
up.gender = post_vars['gender']
|
||||
up.mailing_address = post_vars['mailing_address']
|
||||
up.goals = post_vars['goals']
|
||||
up.level_of_education = post_vars.get('level_of_education')
|
||||
up.gender = post_vars.get('gender')
|
||||
up.mailing_address = post_vars.get('mailing_address')
|
||||
up.goals = post_vars.get('goals')
|
||||
|
||||
try:
|
||||
up.year_of_birth = int(post_vars['year_of_birth'])
|
||||
except ValueError:
|
||||
except (ValueError, KeyError):
|
||||
up.year_of_birth = None # If they give us garbage, just ignore it instead
|
||||
# of asking them to put an integer.
|
||||
try:
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import fs
|
||||
|
||||
import numpy
|
||||
|
||||
@@ -27,7 +28,7 @@ class I4xSystem(object):
|
||||
def __init__(self):
|
||||
self.ajax_url = '/'
|
||||
self.track_function = lambda x: None
|
||||
self.filestore = None
|
||||
self.filestore = fs.osfs.OSFS(os.path.dirname(os.path.realpath(__file__)))
|
||||
self.render_function = lambda x: {} # Probably incorrect
|
||||
self.module_from_xml = lambda x: None # May need a real impl...
|
||||
self.exception404 = Exception
|
||||
|
||||
Reference in New Issue
Block a user