@@ -1083,7 +1083,6 @@ def test_calendar_show_date_from_input(self):
10831083 """
10841084 from selenium .webdriver .common .by import By
10851085
1086- self .selenium .set_window_size (1024 , 768 )
10871086 self .admin_login (username = "super" , password = "secret" , login_url = "/" )
10881087
10891088 # Enter test data
@@ -1096,29 +1095,30 @@ def test_calendar_show_date_from_input(self):
10961095 path = os .path .join (
10971096 os .path .dirname (import_module ("django.contrib.admin" ).__file__ ), "locale"
10981097 )
1099- for language_code , language_name in settings .LANGUAGES :
1100- try :
1101- catalog = gettext .translation ("djangojs" , path , [language_code ])
1102- except OSError :
1103- continue
1104- if month_string in catalog ._catalog :
1105- month_name = catalog ._catalog [month_string ]
1106- else :
1107- month_name = month_string
1108-
1109- # Get the expected caption
1110- may_translation = month_name
1111- expected_caption = "{:s} {:d}" .format (may_translation .upper (), 1984 )
1112-
1113- # Test with every locale
1114- with override_settings (LANGUAGE_CODE = language_code ):
1115- # Open a page that has a date picker widget
1116- url = reverse ("admin:admin_widgets_member_change" , args = (member .pk ,))
1117- self .selenium .get (self .live_server_url + url )
1118- # Click on the calendar icon
1119- self .selenium .find_element (By .ID , "calendarlink0" ).click ()
1120- # Make sure that the right month and year are displayed
1121- self .wait_for_text ("#calendarin0 caption" , expected_caption )
1098+ url = reverse ("admin:admin_widgets_member_change" , args = (member .pk ,))
1099+ with self .small_screen_size ():
1100+ for language_code , language_name in settings .LANGUAGES :
1101+ try :
1102+ catalog = gettext .translation ("djangojs" , path , [language_code ])
1103+ except OSError :
1104+ continue
1105+ if month_string in catalog ._catalog :
1106+ month_name = catalog ._catalog [month_string ]
1107+ else :
1108+ month_name = month_string
1109+
1110+ # Get the expected caption.
1111+ may_translation = month_name
1112+ expected_caption = "{:s} {:d}" .format (may_translation .upper (), 1984 )
1113+
1114+ # Every locale.
1115+ with override_settings (LANGUAGE_CODE = language_code ):
1116+ # Open a page that has a date picker widget.
1117+ self .selenium .get (self .live_server_url + url )
1118+ # Click on the calendar icon.
1119+ self .selenium .find_element (By .ID , "calendarlink0" ).click ()
1120+ # The right month and year are displayed.
1121+ self .wait_for_text ("#calendarin0 caption" , expected_caption )
11221122
11231123
11241124@requires_tz_support
@@ -1416,23 +1416,24 @@ def execute_basic_operations(self, mode, field_name):
14161416 def test_basic (self ):
14171417 from selenium .webdriver .common .by import By
14181418
1419- self .selenium .set_window_size (1024 , 768 )
14201419 self .school .students .set ([self .lisa , self .peter ])
14211420 self .school .alumni .set ([self .lisa , self .peter ])
14221421
1423- self .admin_login (username = "super" , password = "secret" , login_url = "/" )
1424- self .selenium .get (
1425- self .live_server_url
1426- + reverse ("admin:admin_widgets_school_change" , args = (self .school .id ,))
1427- )
1422+ with self .small_screen_size ():
1423+ self .admin_login (username = "super" , password = "secret" , login_url = "/" )
1424+ self .selenium .get (
1425+ self .live_server_url
1426+ + reverse ("admin:admin_widgets_school_change" , args = (self .school .id ,))
1427+ )
14281428
1429- self .wait_page_ready ()
1430- self .execute_basic_operations ("vertical" , "students" )
1431- self .execute_basic_operations ("horizontal" , "alumni" )
1429+ self .wait_page_ready ()
1430+ self .execute_basic_operations ("vertical" , "students" )
1431+ self .execute_basic_operations ("horizontal" , "alumni" )
14321432
1433- # Save and check that everything is properly stored in the database ---
1434- self .selenium .find_element (By .XPATH , '//input[@value="Save"]' ).click ()
1435- self .wait_page_ready ()
1433+ # Save, everything should be stored properly stored in the
1434+ # database.
1435+ self .selenium .find_element (By .XPATH , '//input[@value="Save"]' ).click ()
1436+ self .wait_page_ready ()
14361437 self .school = School .objects .get (id = self .school .id ) # Reload from database
14371438 self .assertEqual (
14381439 list (self .school .students .all ()),
@@ -1451,113 +1452,116 @@ def test_filter(self):
14511452 from selenium .webdriver .common .by import By
14521453 from selenium .webdriver .common .keys import Keys
14531454
1454- self .selenium .set_window_size (1024 , 768 )
14551455 self .school .students .set ([self .lisa , self .peter ])
14561456 self .school .alumni .set ([self .lisa , self .peter ])
14571457
1458- self .admin_login (username = "super" , password = "secret" , login_url = "/" )
1459- self .selenium .get (
1460- self .live_server_url
1461- + reverse ("admin:admin_widgets_school_change" , args = (self .school .id ,))
1462- )
1463-
1464- for field_name in ["students" , "alumni" ]:
1465- from_box = "#id_%s_from" % field_name
1466- to_box = "#id_%s_to" % field_name
1467- choose_link = "id_%s_add_link" % field_name
1468- remove_link = "id_%s_remove_link" % field_name
1469- input = self .selenium .find_element (By .ID , "id_%s_input" % field_name )
1470-
1471- # Initial values
1472- self .assertSelectOptions (
1473- from_box ,
1474- [
1475- str (self .arthur .id ),
1476- str (self .bob .id ),
1477- str (self .cliff .id ),
1478- str (self .jason .id ),
1479- str (self .jenny .id ),
1480- str (self .john .id ),
1481- ],
1458+ with self .small_screen_size ():
1459+ self .admin_login (username = "super" , password = "secret" , login_url = "/" )
1460+ self .selenium .get (
1461+ self .live_server_url
1462+ + reverse ("admin:admin_widgets_school_change" , args = (self .school .id ,))
14821463 )
14831464
1484- # Typing in some characters filters out non-matching options
1485- input .send_keys ("a" )
1486- self .assertSelectOptions (
1487- from_box , [str (self .arthur .id ), str (self .jason .id )]
1488- )
1489- input .send_keys ("R" )
1490- self .assertSelectOptions (from_box , [str (self .arthur .id )])
1465+ for field_name in ["students" , "alumni" ]:
1466+ from_box = "#id_%s_from" % field_name
1467+ to_box = "#id_%s_to" % field_name
1468+ choose_link = "id_%s_add_link" % field_name
1469+ remove_link = "id_%s_remove_link" % field_name
1470+ input = self .selenium .find_element (By .ID , "id_%s_input" % field_name )
1471+ # Initial values.
1472+ self .assertSelectOptions (
1473+ from_box ,
1474+ [
1475+ str (self .arthur .id ),
1476+ str (self .bob .id ),
1477+ str (self .cliff .id ),
1478+ str (self .jason .id ),
1479+ str (self .jenny .id ),
1480+ str (self .john .id ),
1481+ ],
1482+ )
1483+ # Typing in some characters filters out non-matching options.
1484+ input .send_keys ("a" )
1485+ self .assertSelectOptions (
1486+ from_box , [str (self .arthur .id ), str (self .jason .id )]
1487+ )
1488+ input .send_keys ("R" )
1489+ self .assertSelectOptions (from_box , [str (self .arthur .id )])
1490+ # Clearing the text box makes the other options reappear.
1491+ input .send_keys ([Keys .BACK_SPACE ])
1492+ self .assertSelectOptions (
1493+ from_box , [str (self .arthur .id ), str (self .jason .id )]
1494+ )
1495+ input .send_keys ([Keys .BACK_SPACE ])
1496+ self .assertSelectOptions (
1497+ from_box ,
1498+ [
1499+ str (self .arthur .id ),
1500+ str (self .bob .id ),
1501+ str (self .cliff .id ),
1502+ str (self .jason .id ),
1503+ str (self .jenny .id ),
1504+ str (self .john .id ),
1505+ ],
1506+ )
14911507
1492- # Clearing the text box makes the other options reappear
1493- input .send_keys ([Keys .BACK_SPACE ])
1494- self .assertSelectOptions (
1495- from_box , [str (self .arthur .id ), str (self .jason .id )]
1496- )
1497- input .send_keys ([Keys .BACK_SPACE ])
1498- self .assertSelectOptions (
1499- from_box ,
1500- [
1501- str (self .arthur .id ),
1502- str (self .bob .id ),
1503- str (self .cliff .id ),
1504- str (self .jason .id ),
1505- str (self .jenny .id ),
1506- str (self .john .id ),
1507- ],
1508- )
1508+ # Choosing a filtered option sends it properly to the 'to' box.
1509+ input .send_keys ("a" )
1510+ self .assertSelectOptions (
1511+ from_box , [str (self .arthur .id ), str (self .jason .id )]
1512+ )
1513+ self .select_option (from_box , str (self .jason .id ))
1514+ self .selenium .find_element (By .ID , choose_link ).click ()
1515+ self .assertSelectOptions (from_box , [str (self .arthur .id )])
1516+ self .assertSelectOptions (
1517+ to_box ,
1518+ [
1519+ str (self .lisa .id ),
1520+ str (self .peter .id ),
1521+ str (self .jason .id ),
1522+ ],
1523+ )
15091524
1510- # -----------------------------------------------------------------
1511- # Choosing a filtered option sends it properly to the 'to' box.
1512- input .send_keys ("a" )
1513- self .assertSelectOptions (
1514- from_box , [str (self .arthur .id ), str (self .jason .id )]
1515- )
1516- self .select_option (from_box , str (self .jason .id ))
1517- self .selenium .find_element (By .ID , choose_link ).click ()
1518- self .assertSelectOptions (from_box , [str (self .arthur .id )])
1519- self .assertSelectOptions (
1520- to_box ,
1521- [
1522- str (self .lisa .id ),
1523- str (self .peter .id ),
1524- str (self .jason .id ),
1525- ],
1526- )
1525+ self .select_option (to_box , str (self .lisa .id ))
1526+ self .selenium .find_element (By .ID , remove_link ).click ()
1527+ self .assertSelectOptions (
1528+ from_box , [str (self .arthur .id ), str (self .lisa .id )]
1529+ )
1530+ self .assertSelectOptions (
1531+ to_box , [str (self .peter .id ), str (self .jason .id )]
1532+ )
15271533
1528- self .select_option (to_box , str (self .lisa .id ))
1529- self .selenium .find_element (By .ID , remove_link ).click ()
1530- self .assertSelectOptions (from_box , [str (self .arthur .id ), str (self .lisa .id )])
1531- self .assertSelectOptions (to_box , [str (self .peter .id ), str (self .jason .id )])
1532-
1533- input .send_keys ([Keys .BACK_SPACE ]) # Clear text box
1534- self .assertSelectOptions (
1535- from_box ,
1536- [
1537- str (self .arthur .id ),
1538- str (self .bob .id ),
1539- str (self .cliff .id ),
1540- str (self .jenny .id ),
1541- str (self .john .id ),
1542- str (self .lisa .id ),
1543- ],
1544- )
1545- self .assertSelectOptions (to_box , [str (self .peter .id ), str (self .jason .id )])
1534+ input .send_keys ([Keys .BACK_SPACE ]) # Clear text box
1535+ self .assertSelectOptions (
1536+ from_box ,
1537+ [
1538+ str (self .arthur .id ),
1539+ str (self .bob .id ),
1540+ str (self .cliff .id ),
1541+ str (self .jenny .id ),
1542+ str (self .john .id ),
1543+ str (self .lisa .id ),
1544+ ],
1545+ )
1546+ self .assertSelectOptions (
1547+ to_box , [str (self .peter .id ), str (self .jason .id )]
1548+ )
15461549
1547- # -----------------------------------------------------------------
1548- # Pressing enter on a filtered option sends it properly to
1549- # the 'to' box.
1550- self .select_option (to_box , str (self .jason .id ))
1551- self .selenium .find_element (By .ID , remove_link ).click ()
1552- input .send_keys ("ja" )
1553- self .assertSelectOptions (from_box , [str (self .jason .id )])
1554- input .send_keys ([Keys .ENTER ])
1555- self .assertSelectOptions (to_box , [str (self .peter .id ), str (self .jason .id )])
1556- input .send_keys ([Keys .BACK_SPACE , Keys .BACK_SPACE ])
1550+ # Pressing enter on a filtered option sends it properly to
1551+ # the 'to' box.
1552+ self .select_option (to_box , str (self .jason .id ))
1553+ self .selenium .find_element (By .ID , remove_link ).click ()
1554+ input .send_keys ("ja" )
1555+ self .assertSelectOptions (from_box , [str (self .jason .id )])
1556+ input .send_keys ([Keys .ENTER ])
1557+ self .assertSelectOptions (
1558+ to_box , [str (self .peter .id ), str (self .jason .id )]
1559+ )
1560+ input .send_keys ([Keys .BACK_SPACE , Keys .BACK_SPACE ])
15571561
1558- # Save and check that everything is properly stored in the database ---
1559- with self .wait_page_loaded ():
1560- self .selenium .find_element (By .XPATH , '//input[@value="Save"]' ).click ()
1562+ # Save, everything should be stored properly in the database.
1563+ with self .wait_page_loaded ():
1564+ self .selenium .find_element (By .XPATH , '//input[@value="Save"]' ).click ()
15611565 self .school = School .objects .get (id = self .school .id ) # Reload from database
15621566 self .assertEqual (list (self .school .students .all ()), [self .jason , self .peter ])
15631567 self .assertEqual (list (self .school .alumni .all ()), [self .jason , self .peter ])
0 commit comments