Acceptance test for language selector
Tests language selection feature for student dashboard
This commit is contained in:
committed by
thedeadparrot
parent
a5207708f8
commit
d867e87b72
@@ -1,24 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
This test file will verify functionality relating to changing language settings for a user
|
||||
"""
|
||||
from django.test import TestCase
|
||||
from django.core.urlresolvers import reverse
|
||||
from student.tests.factories import UserFactory
|
||||
|
||||
|
||||
class TestLanguageSettings(TestCase):
|
||||
"""
|
||||
Language settings tests
|
||||
"""
|
||||
def setUp(self):
|
||||
self.user = UserFactory.create(username="rusty", password="test")
|
||||
self.client.login(username="rusty", password="test")
|
||||
|
||||
def test_successful_language_change(self):
|
||||
# Esperanto is our dummy language
|
||||
post_data = dict(language='eo',)
|
||||
response = self.client.post('/i18n/setlang/', data=post_data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
session = self.client.session
|
||||
self.assertEqual(session['django_language'], 'eo')
|
||||
@@ -61,7 +61,10 @@ class DashboardPage(PageObject):
|
||||
else:
|
||||
return None
|
||||
|
||||
def change_language(self):
|
||||
def change_language(self, code):
|
||||
"""
|
||||
Change the language on the dashboard to the language corresponding with `code`.
|
||||
"""
|
||||
self.css_click(".edit-language")
|
||||
self.select_option("language", "eo")
|
||||
self.select_option("language", code)
|
||||
self.css_click("#submit-lang")
|
||||
|
||||
@@ -81,17 +81,17 @@ class LanguageTest(UniqueCourseTest):
|
||||
"""
|
||||
super(LanguageTest, self).setUp()
|
||||
self.dashboard_page = DashboardPage(self.browser)
|
||||
|
||||
|
||||
def test_change_lang(self):
|
||||
AutoAuthPage(self.browser, course_id=self.course_id).visit()
|
||||
self.dashboard_page.visit()
|
||||
# Change language to Esperanto
|
||||
self.dashboard_page.change_language()
|
||||
self.fail()
|
||||
# Change language to Dummy Esperanto
|
||||
self.dashboard_page.change_language("eo")
|
||||
self.dashboard_page.visit()
|
||||
body = self.browser.body
|
||||
matches = re.match(u'^FÏND ÇØÜRSÉS.+$', body)
|
||||
self.assertTrue(matches is not None)
|
||||
# This string is unicode for "ÇÜRRÉNT ÇØÜRSÉS", which should appear in our Dummy Esperanto page
|
||||
seektext = u"\xc7\xdcRR\xc9NT \xc7\xd8\xdcRS\xc9S"
|
||||
self.browser.is_text_present(seektext)
|
||||
self.assertTrue(self.browser.is_text_present(seektext))
|
||||
|
||||
|
||||
class HighLevelTabTest(UniqueCourseTest):
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"pk": 1, "model": "dark_lang.darklangconfig", "fields": {"change_date": "2014-01-30T20:34:20Z", "changed_by": null, "enabled": true, "released_languages": "en,eo"}}]
|
||||
[{"pk": 1, "model": "dark_lang.darklangconfig", "fields": {"change_date": "2100-01-30T20:34:20Z", "changed_by": null, "enabled": true, "released_languages": "en,eo"}}]
|
||||
|
||||
@@ -12,6 +12,3 @@
|
||||
</span>
|
||||
<span class="data">${current_language['name_local']}</span>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
<ul class="list-actions">
|
||||
<li class="action-item">
|
||||
<button type="submit" class="action action-submit" id="#submit-lang">Save Language</button>
|
||||
<button type="submit" class="action action-submit" id="submit-lang">Save Language</button>
|
||||
</li>
|
||||
<li class="action-item">
|
||||
<button type="reset" class="action action-cancel">Cancel</button>
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace :'test:bok_choy' do
|
||||
# Clear any test data already in Mongo or MySQL and invalidate the cache
|
||||
clear_mongo()
|
||||
BOK_CHOY_CACHE.flush()
|
||||
sh(django_admin('lms', 'bok_choy', 'flush', '--noinput'))
|
||||
sh(django_admin('lms', 'bok_choy', 'loaddata', 'common/test/db_fixtures/*.json'))
|
||||
|
||||
# Ensure the test servers are available
|
||||
puts "Starting test servers...".green
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
############################################################################
|
||||
|
||||
DB_CACHE_DIR="common/test/db_cache"
|
||||
DB_FIXTURE_DIR="common/test/db_fixtures"
|
||||
|
||||
# Clear out the test database
|
||||
./manage.py lms --settings bok_choy reset_db --traceback --noinput
|
||||
@@ -53,5 +52,3 @@ else
|
||||
mysqldump -u root --no-data --skip-comments --skip-dump-date test > $DB_CACHE_DIR/bok_choy_schema.sql
|
||||
fi
|
||||
|
||||
# Load database fixtures
|
||||
./manage.py lms --settings bok_choy loaddata $DB_FIXTURE_DIR/*.json
|
||||
|
||||
Reference in New Issue
Block a user