Commit 3fb65924 by Awais Jibran Committed by attiyaishaque

SUST-24 Initial commit

Add bokchoy test and changes in html
parent 7b34f431
......@@ -286,3 +286,23 @@ class CoursewareSequentialTabPage(CoursePage):
return the body of the sequential currently selected
"""
return self.q(css='#seq_content .xblock').text[0]
class AboutPage(CoursePage):
"""
Course about.
"""
url_path = "about/"
def is_browser_on_page(self):
return self.q(css='.intro').present
@property
def is_register_button_present(self):
"""
Returns True if the timed/proctored exam timer bar is visible on the courseware.
"""
from nose.tools import set_trace; set_trace()
return self.q(css=".register").is_present()
......@@ -5,6 +5,7 @@ Studio Home page
from bok_choy.page_object import PageObject
from . import BASE_URL
from selenium.webdriver import ActionChains
from ..common.utils import click_css
class DashboardPage(PageObject):
......@@ -12,11 +13,24 @@ class DashboardPage(PageObject):
Studio Home page
"""
def __init__(self, browser):
"""
Initialize the page.
"""
super(DashboardPage, self).__init__(browser)
url = BASE_URL + "/course/"
def is_browser_on_page(self):
return self.q(css='.content-primary').visible
def mouse_hover(self, element):
"""
Mouse over on given element.
"""
mouse_hover_action = ActionChains(self.browser).move_to_element(element)
mouse_hover_action.perform()
@property
def course_runs(self):
"""
......@@ -48,6 +62,16 @@ class DashboardPage(PageObject):
# Clicking on course with run will trigger an ajax event
self.wait_for_ajax()
def view_live(self, element):
"""
Clicks the "View Live" link and switches to the new tab
"""
self.mouse_hover(self.browser.find_element_by_css_selector('.view-button'))
click_css(self, '.view-button', require_notification=False)
self.browser.switch_to_window(self.browser.window_handles[-1])
click_css(self, element, require_notification=False)
def has_new_library_button(self):
"""
(bool) is the "New Library" button present?
......
......@@ -11,6 +11,7 @@ from ...pages.studio.overview import CourseOutlinePage
from ...pages.studio.utils import verify_ordering
class StudioCourseTest(UniqueCourseTest):
"""
Base class for all Studio course tests.
......
"""
Acceptance tests for Home Page (My Courses / My Libraries).
"""
import os
import uuid
from bok_choy.web_app_test import WebAppTest
from common.test.acceptance.pages.common.logout import LogoutPage
from common.test.acceptance.pages.lms.courseware import AboutPage, CoursewarePage
from flaky import flaky
from opaque_keys.edx.locator import LibraryLocator
from opaque_keys.edx.locator import LibraryLocator, CourseLocator
from uuid import uuid4
from ...fixtures import PROGRAMS_STUB_URL
......@@ -173,3 +178,74 @@ class StudioLanguageTest(WebAppTest):
get_selected_option_text(language_selector),
u'Dummy Language (Esperanto)'
)
class CourseNotEnrollTest(WebAppTest):
"""
Test that we can create a new content library on the studio home page.
"""
def setUp(self):
"""
Load the helper for the home page (dashboard page)
"""
super(CourseNotEnrollTest, self).setUp()
self.auth_page = AutoAuthPage(self.browser, staff=True)
self.dashboard_page = DashboardPage(self.browser)
self.course_name = "New Course Name"
self.course_org = "orgX"
self.course_number = str(uuid.uuid4().get_hex().upper()[0:6])
self.course_run = "2015_T2"
def course_id(self):
"""
Returns the serialized course_key for the test
"""
# TODO - is there a better way to make this agnostic to the underlying default module store?
default_store = os.environ.get('DEFAULT_STORE', 'draft')
course_key = CourseLocator(
self.course_org,
self.course_number,
self.course_run,
deprecated=(default_store == 'draft')
)
return unicode(course_key)
def test_unenroll_course(self):
"""
From the home page:
Click "New Course" ,Fill out the form
Submit the form
Return to the home page and logout
Login with the staff user which is not enrolled in the course
click the view live button of the course
Here are two scenario:
First click the continue button
Second click the Enroll button and see the response.
"""
self.auth_page.visit()
self.dashboard_page.visit()
self.assertTrue(self.dashboard_page.new_course_button.present)
self.dashboard_page.click_new_course_button()
self.assertTrue(self.dashboard_page.is_new_course_form_visible())
self.dashboard_page.fill_new_course_form(
self.course_name, self.course_org, self.course_number, self.course_run
)
self.assertTrue(self.dashboard_page.is_new_course_form_valid())
self.dashboard_page.submit_new_course_form()
LogoutPage(self.browser).visit()
AutoAuthPage(self.browser, course_id=None, staff=True).visit()
self.dashboard_page.visit()
self.dashboard_page.view_live('.submit>input:last-child')
about_page = AboutPage(self.browser, self.course_id)
about_page.wait_for_page()
self.assertTrue(about_page.is_register_button_present)
self.dashboard_page.visit()
self.dashboard_page.view_live('.submit>input:first-child')
courseware = CoursewarePage(self.browser, self.course_id)
courseware.wait_for_page()
self.assertTrue(courseware.is_browser_on_page())
\ No newline at end of file
......@@ -1449,6 +1449,14 @@ class DefaultStatesContentTest(CourseOutlineTest):
self.assertEqual(courseware.xblock_component_type(1), 'html')
self.assertEqual(courseware.xblock_component_type(2), 'discussion')
def test_unenroll_course(self):
from nose.tools import set_trace; set_trace()
self.course_outline_page.visit()
self.course_outline_page.view_live()
courseware = CoursewarePage(self.browser, self.course_id)
courseware.wait_for_page()
self.assertEqual(courseware.num_xblock_components, 3)
@attr('shard_3')
class UnitNavigationTest(CourseOutlineTest):
......
......@@ -222,7 +222,6 @@ class GeneratedCertificate(models.Model):
MODES = Choices('verified', 'honor', 'audit', 'professional', 'no-id-professional')
VERIFIED_CERTS_MODES = [CourseMode.VERIFIED, CourseMode.CREDIT_MODE]
user = models.ForeignKey(User)
course_id = CourseKeyField(max_length=255, blank=True, default=None)
verify_uuid = models.CharField(max_length=32, blank=True, default='', db_index=True)
......
......@@ -3289,7 +3289,6 @@ def validate_request_data_and_get_certificate(certificate_invalidation, course_k
)
student = get_student(user, course_key)
certificate = GeneratedCertificate.certificate_for_student(student, course_key)
if not certificate:
raise ValueError(_(
......
......@@ -446,6 +446,7 @@ def submit_export_ora2_data(request, course_key):
def generate_certificates_for_students(request, course_key, student_set=None, specific_student_id=None): # pylint: disable=invalid-name
"""
<<<<<<< HEAD
Submits a task to generate certificates for given students enrolled in the course.
Arguments:
......
<%inherit file="main.html" />
<%namespace name='static' file='static_content.html'/>
<%!
from django.utils.translation import ugettext as _
from courseware.courses import get_course_info_section, get_course_date_summary
%>
<%block name="pagetitle">${_("{course_number} Course Info").format(course_number=course.display_number_with_default)}</%block>
<%block name="headextra">
<%static:css group='style-course-vendor'/>
<%static:css group='style-course'/>
</%block>
<%block name="bodyclass">view-in-course view-course-info ${course.css_class or ''}</%block>
<div class="login-register">
<section class="form-type">
<section role="main" class="content">
<div id="unenroll_error" class="modal-form-error"></div>
<div id="${course.id.to_deprecated_string()}" >
<h3> ${_("You should Register before trying to access and Unit")}</h3>
<form role="form" id="enroll_staff_form" method="post" action="">
<input type="hidden" name="csrfmiddlewaretoken" value="${ csrftoken }"/>
<div class="submit ">
<input name="enroll" type="submit" value="${_(" Enroll")}" />
<input name="continue" type="submit" value="${_(" Continue")}" />
</div>
</form>
</div>
</section>
</section>
</div>
......@@ -366,6 +366,14 @@ urlpatterns += (
name='about_course',
),
url(
r'^courses/{}/enroll_staff$'.format(
settings.COURSE_ID_PATTERN,
),
'courseware.views.enroll_staff',
name='enroll_staff',
),
#Inside the course
url(
r'^courses/{}/$'.format(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment