Fixed admin selenium tests broken by removal of fixtures.

This commit is contained in:
Tim Graham 2015-03-05 08:21:29 -05:00
parent 668d53cd12
commit 82f7bee1d5
4 changed files with 42 additions and 27 deletions

View File

@ -674,8 +674,7 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
available_apps = ['admin_changelist'] + AdminSeleniumWebDriverTestCase.available_apps available_apps = ['admin_changelist'] + AdminSeleniumWebDriverTestCase.available_apps
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
@classmethod def setUp(self):
def setUpTestData(cls):
# password = "secret" # password = "secret"
User.objects.create( User.objects.create(
pk=100, username='super', first_name='Super', last_name='User', email='super@example.com', pk=100, username='super', first_name='Super', last_name='User', email='super@example.com',

View File

@ -667,11 +667,20 @@ class TestInlinePermissions(TestCase):
@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
ROOT_URLCONF="admin_inlines.urls") ROOT_URLCONF="admin_inlines.urls")
class SeleniumFirefoxTests(TestDataMixin, AdminSeleniumWebDriverTestCase): class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
available_apps = ['admin_inlines'] + AdminSeleniumWebDriverTestCase.available_apps available_apps = ['admin_inlines'] + AdminSeleniumWebDriverTestCase.available_apps
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
def setUp(self):
# password = "secret"
User.objects.create(
pk=100, username='super', first_name='Super', last_name='User', email='super@example.com',
password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', is_active=True, is_superuser=True,
is_staff=True, last_login=datetime.datetime(2007, 5, 30, 13, 20, 10),
date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10)
)
def test_add_stackeds(self): def test_add_stackeds(self):
""" """
Ensure that the "Add another XXX" link correctly adds items to the Ensure that the "Add another XXX" link correctly adds items to the

View File

@ -4298,15 +4298,14 @@ class SeleniumAdminViewsFirefoxTests(AdminSeleniumWebDriverTestCase):
available_apps = ['admin_views'] + AdminSeleniumWebDriverTestCase.available_apps available_apps = ['admin_views'] + AdminSeleniumWebDriverTestCase.available_apps
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
@classmethod def setUp(self):
def setUpTestData(cls): self.u1 = User.objects.create(
cls.u1 = User.objects.create(
id=100, password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', id=100, password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158',
last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super',
first_name='Super', last_name='User', email='super@example.com', first_name='Super', last_name='User', email='super@example.com',
is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10)
) )
cls.p1 = PrePopulatedPost.objects.create(title='A Long Title', published=True, slug='a-long-title') self.p1 = PrePopulatedPost.objects.create(title='A Long Title', published=True, slug='a-long-title')
def test_prepopulated_fields(self): def test_prepopulated_fields(self):
""" """

View File

@ -49,6 +49,16 @@ class TestDataMixin(object):
models.Car.objects.create(id=2, owner=cls.u2, make='BMW', model='M3') models.Car.objects.create(id=2, owner=cls.u2, make='BMW', model='M3')
class SeleniumDataMixin(object):
def setUp(self):
self.u1 = User.objects.create(
pk=100, username='super', first_name='Super', last_name='User', email='super@example.com',
password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', is_active=True, is_superuser=True,
is_staff=True, last_login=datetime(2007, 5, 30, 13, 20, 10),
date_joined=datetime(2007, 5, 30, 13, 20, 10)
)
class AdminFormfieldForDBFieldTests(TestCase): class AdminFormfieldForDBFieldTests(TestCase):
""" """
Tests for correct behavior of ModelAdmin.formfield_for_dbfield Tests for correct behavior of ModelAdmin.formfield_for_dbfield
@ -587,7 +597,7 @@ class RelatedFieldWidgetWrapperTests(DjangoTestCase):
@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
ROOT_URLCONF='admin_widgets.urls') ROOT_URLCONF='admin_widgets.urls')
class DateTimePickerSeleniumFirefoxTests(TestDataMixin, AdminSeleniumWebDriverTestCase): class DateTimePickerSeleniumFirefoxTests(SeleniumDataMixin, AdminSeleniumWebDriverTestCase):
available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
@ -764,7 +774,7 @@ class DateTimePickerSeleniumIETests(DateTimePickerSeleniumFirefoxTests):
@override_settings(TIME_ZONE='Asia/Singapore') @override_settings(TIME_ZONE='Asia/Singapore')
@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
ROOT_URLCONF='admin_widgets.urls') ROOT_URLCONF='admin_widgets.urls')
class DateTimePickerShortcutsSeleniumFirefoxTests(TestDataMixin, AdminSeleniumWebDriverTestCase): class DateTimePickerShortcutsSeleniumFirefoxTests(SeleniumDataMixin, AdminSeleniumWebDriverTestCase):
available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
@ -831,23 +841,22 @@ class DateTimePickerShortcutsSeleniumIETests(DateTimePickerShortcutsSeleniumFire
@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
ROOT_URLCONF='admin_widgets.urls') ROOT_URLCONF='admin_widgets.urls')
class HorizontalVerticalFilterSeleniumFirefoxTests(TestDataMixin, AdminSeleniumWebDriverTestCase): class HorizontalVerticalFilterSeleniumFirefoxTests(SeleniumDataMixin, AdminSeleniumWebDriverTestCase):
available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
@classmethod def setUp(self):
def setUpTestData(cls): super(HorizontalVerticalFilterSeleniumFirefoxTests, self).setUp()
super(HorizontalVerticalFilterSeleniumFirefoxTests, cls).setUpTestData() self.lisa = models.Student.objects.create(name='Lisa')
cls.lisa = models.Student.objects.create(name='Lisa') self.john = models.Student.objects.create(name='John')
cls.john = models.Student.objects.create(name='John') self.bob = models.Student.objects.create(name='Bob')
cls.bob = models.Student.objects.create(name='Bob') self.peter = models.Student.objects.create(name='Peter')
cls.peter = models.Student.objects.create(name='Peter') self.jenny = models.Student.objects.create(name='Jenny')
cls.jenny = models.Student.objects.create(name='Jenny') self.jason = models.Student.objects.create(name='Jason')
cls.jason = models.Student.objects.create(name='Jason') self.cliff = models.Student.objects.create(name='Cliff')
cls.cliff = models.Student.objects.create(name='Cliff') self.arthur = models.Student.objects.create(name='Arthur')
cls.arthur = models.Student.objects.create(name='Arthur') self.school = models.School.objects.create(name='School of Awesome')
cls.school = models.School.objects.create(name='School of Awesome')
def assertActiveButtons(self, mode, field_name, choose, remove, def assertActiveButtons(self, mode, field_name, choose, remove,
choose_all=None, remove_all=None): choose_all=None, remove_all=None):
@ -1086,13 +1095,12 @@ class HorizontalVerticalFilterSeleniumIETests(HorizontalVerticalFilterSeleniumFi
@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
ROOT_URLCONF='admin_widgets.urls') ROOT_URLCONF='admin_widgets.urls')
class AdminRawIdWidgetSeleniumFirefoxTests(TestDataMixin, AdminSeleniumWebDriverTestCase): class AdminRawIdWidgetSeleniumFirefoxTests(SeleniumDataMixin, AdminSeleniumWebDriverTestCase):
available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
@classmethod def setUp(self):
def setUpTestData(cls): super(AdminRawIdWidgetSeleniumFirefoxTests, self).setUp()
super(AdminRawIdWidgetSeleniumFirefoxTests, cls).setUpTestData()
models.Band.objects.create(id=42, name='Bogey Blues') models.Band.objects.create(id=42, name='Bogey Blues')
models.Band.objects.create(id=98, name='Green Potatoes') models.Band.objects.create(id=98, name='Green Potatoes')
@ -1177,7 +1185,7 @@ class AdminRawIdWidgetSeleniumIETests(AdminRawIdWidgetSeleniumFirefoxTests):
@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
ROOT_URLCONF='admin_widgets.urls') ROOT_URLCONF='admin_widgets.urls')
class RelatedFieldWidgetSeleniumFirefoxTests(TestDataMixin, AdminSeleniumWebDriverTestCase): class RelatedFieldWidgetSeleniumFirefoxTests(SeleniumDataMixin, AdminSeleniumWebDriverTestCase):
available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'