new FT test_theme for theme switcher functionality; theme-switcher content added to home.html, several dashboard views & urls, all appropriate ITs & UTs; lyric user model saves theme (migrations run); django-compressor and django-libsass libraries added to dependencies
This commit is contained in:
@@ -255,3 +255,50 @@ class ViewAuthListTest(TestCase):
|
||||
self.client.force_login(guest)
|
||||
response = self.client.get(reverse("view_list", args=[self.our_list.id]))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
class SetThemeTest(TestCase):
|
||||
def setUp(self):
|
||||
self.user = User.objects.create(email="a@b.cde")
|
||||
self.client.force_login(self.user)
|
||||
self.url = reverse("home")
|
||||
|
||||
def test_anonymous_user_is_redirected_home(self):
|
||||
response = self.client.post("/dashboard/set_theme")
|
||||
self.assertRedirects(response, "/")
|
||||
|
||||
def test_set_theme_updates_user_theme(self):
|
||||
User.objects.filter(pk=self.user.pk).update(theme="theme-sheol")
|
||||
self.client.post("/dashboard/set_theme", data={"theme": "theme-default"})
|
||||
self.user.refresh_from_db()
|
||||
self.assertEqual(self.user.theme, "theme-default")
|
||||
|
||||
def test_locked_theme_is_rejected(self):
|
||||
response = self.client.post("/dashboard/set_theme", data={"theme": "theme-nirvana"})
|
||||
self.user.refresh_from_db()
|
||||
self.assertEqual(self.user.theme, "theme-default")
|
||||
self.assertRedirects(response, "/")
|
||||
|
||||
def test_set_theme_redirects_home(self):
|
||||
response = self.client.post("/dashboard/set_theme", data={"theme": "theme-default"})
|
||||
self.assertRedirects(response, "/")
|
||||
|
||||
def test_my_lists_contains_set_theme_form(self):
|
||||
response = self.client.get(self.url)
|
||||
parsed = lxml.html.fromstring(response.content)
|
||||
forms = parsed.cssselect('form[action="/dashboard/set_theme"]')
|
||||
self.assertEqual(len(forms), 1)
|
||||
|
||||
def test_active_theme_swatch_has_active_class(self):
|
||||
response = self.client.get(self.url)
|
||||
parsed = lxml.html.fromstring(response.content)
|
||||
[active] = parsed.cssselect(".swatch.active")
|
||||
self.assertIn("theme-default", active.classes)
|
||||
|
||||
def test_locked_themes_are_not_forms(self):
|
||||
response = self.client.get(self.url)
|
||||
parsed = lxml.html.fromstring(response.content)
|
||||
locked = parsed.cssselect(".swatch.locked")
|
||||
self.assertEqual(len(locked), 2)
|
||||
# they mustn't be button els
|
||||
for swatch in locked:
|
||||
self.assertNotEqual(swatch.tag, "button")
|
||||
|
||||
Reference in New Issue
Block a user