summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Phalip <jphalip@gmail.com>2012-03-04 04:50:58 +0000
committerJulien Phalip <jphalip@gmail.com>2012-03-04 04:50:58 +0000
commit794fe19e196b98533ee539d35fd7ab7f688166b7 (patch)
tree1b58c3470697da0a239a7f62c20d209cfd13add9
parent4dca9d166a42717b7d7bf5cf3c5da8149cf88cb2 (diff)
Made the Selenium tests for the admin horizontal/vertical filter widgets a bit more thorough.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17649 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--tests/regressiontests/admin_widgets/tests.py30
1 files changed, 25 insertions, 5 deletions
diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py
index 866e5a7db5..94ee5a9fe9 100644
--- a/tests/regressiontests/admin_widgets/tests.py
+++ b/tests/regressiontests/admin_widgets/tests.py
@@ -624,7 +624,8 @@ class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCas
for field_name in ['students', 'alumni']:
from_box = '#id_%s_from' % field_name
to_box = '#id_%s_to' % field_name
- choose_link = 'id_%s_add_link' % field_name
+ choose_link = '#id_%s_add_link' % field_name
+ remove_link = '#id_%s_remove_link' % field_name
input = self.selenium.find_element_by_css_selector('#id_%s_input' % field_name)
# Initial values
@@ -648,21 +649,40 @@ class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCas
str(self.cliff.id), str(self.jason.id),
str(self.jenny.id), str(self.john.id)])
+ # -----------------------------------------------------------------
# Check that chosing a filtered option sends it properly to the
# 'to' box.
input.send_keys('a')
self.assertSelectOptions(from_box, [str(self.arthur.id), str(self.jason.id)])
self.get_select_option(from_box, str(self.jason.id)).click()
- self.selenium.find_element_by_id(choose_link).click()
+ self.selenium.find_element_by_css_selector(choose_link).click()
self.assertSelectOptions(from_box, [str(self.arthur.id)])
+ self.assertSelectOptions(to_box,
+ [str(self.lisa.id), str(self.peter.id),
+ str(self.jason.id)])
+
+ self.get_select_option(to_box, str(self.lisa.id)).click()
+ self.selenium.find_element_by_css_selector(remove_link).click()
+ self.assertSelectOptions(from_box,
+ [str(self.arthur.id), str(self.lisa.id)])
+ self.assertSelectOptions(to_box,
+ [str(self.peter.id), str(self.jason.id)])
+
input.send_keys([Keys.BACK_SPACE]) # Clear text box
self.assertSelectOptions(from_box,
[str(self.arthur.id), str(self.bob.id),
str(self.cliff.id), str(self.jenny.id),
- str(self.john.id)])
+ str(self.john.id), str(self.lisa.id)])
self.assertSelectOptions(to_box,
- [str(self.lisa.id), str(self.peter.id),
- str(self.jason.id)])
+ [str(self.peter.id), str(self.jason.id)])
+
+ # Save and check that everything is properly stored in the database ---
+ self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
+ self.school = models.School.objects.get(id=self.school.id) # Reload from database
+ self.assertEqual(list(self.school.students.all()),
+ [self.jason, self.peter])
+ self.assertEqual(list(self.school.alumni.all()),
+ [self.jason, self.peter])
class HorizontalVerticalFilterSeleniumChromeTests(HorizontalVerticalFilterSeleniumFirefoxTests):
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver' \ No newline at end of file