From d867e87b727483d4cbe81e911c019b50bbe4a519 Mon Sep 17 00:00:00 2001 From: Julia Hansbrough <julia@edx.org> Date: Thu, 6 Feb 2014 16:38:16 +0000 Subject: [PATCH] Acceptance test for language selector Tests language selection feature for student dashboard --- .../student/tests/test_languages.py | 24 ------------------- common/test/acceptance/pages/lms/dashboard.py | 7 ++++-- common/test/acceptance/tests/test_lms.py | 14 +++++------ common/test/db_fixtures/released_lang.json | 2 +- .../dashboard/_dashboard_info_language.html | 3 --- .../modal/_modal-settings-language.html | 2 +- rakelib/bok_choy.rake | 2 +- scripts/reset-test-db.sh | 3 --- 8 files changed, 15 insertions(+), 42 deletions(-) delete mode 100644 common/djangoapps/student/tests/test_languages.py diff --git a/common/djangoapps/student/tests/test_languages.py b/common/djangoapps/student/tests/test_languages.py deleted file mode 100644 index 42d100672ec..00000000000 --- a/common/djangoapps/student/tests/test_languages.py +++ /dev/null @@ -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') diff --git a/common/test/acceptance/pages/lms/dashboard.py b/common/test/acceptance/pages/lms/dashboard.py index eaa5c83b834..12e033b2f04 100644 --- a/common/test/acceptance/pages/lms/dashboard.py +++ b/common/test/acceptance/pages/lms/dashboard.py @@ -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") diff --git a/common/test/acceptance/tests/test_lms.py b/common/test/acceptance/tests/test_lms.py index 535c3eaf02e..28ff4d5ac40 100644 --- a/common/test/acceptance/tests/test_lms.py +++ b/common/test/acceptance/tests/test_lms.py @@ -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): diff --git a/common/test/db_fixtures/released_lang.json b/common/test/db_fixtures/released_lang.json index f129e5aa4c1..7c6f1d0d421 100644 --- a/common/test/db_fixtures/released_lang.json +++ b/common/test/db_fixtures/released_lang.json @@ -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"}}] diff --git a/lms/templates/dashboard/_dashboard_info_language.html b/lms/templates/dashboard/_dashboard_info_language.html index 2f1a3ca158d..c544a372b04 100644 --- a/lms/templates/dashboard/_dashboard_info_language.html +++ b/lms/templates/dashboard/_dashboard_info_language.html @@ -12,6 +12,3 @@ </span> <span class="data">${current_language['name_local']}</span> </li> - - - diff --git a/lms/templates/modal/_modal-settings-language.html b/lms/templates/modal/_modal-settings-language.html index 6a7cdbd5f8c..1c1a26d9fdf 100644 --- a/lms/templates/modal/_modal-settings-language.html +++ b/lms/templates/modal/_modal-settings-language.html @@ -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> diff --git a/rakelib/bok_choy.rake b/rakelib/bok_choy.rake index 35bf7335ff1..c2809dcd687 100644 --- a/rakelib/bok_choy.rake +++ b/rakelib/bok_choy.rake @@ -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 diff --git a/scripts/reset-test-db.sh b/scripts/reset-test-db.sh index 582d1ab827e..a0808c208a4 100755 --- a/scripts/reset-test-db.sh +++ b/scripts/reset-test-db.sh @@ -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 -- GitLab