added frontend tests; test_view_by_anonymous is now by anonymous
parent
c703b1b367
commit
22da90659c
|
@ -18,25 +18,42 @@ class WishlistTests(TestCase):
|
||||||
self.assertEqual(r.status_code, 302)
|
self.assertEqual(r.status_code, 302)
|
||||||
self.assertEqual(self.user.wishlist.works.all().count(), 1)
|
self.assertEqual(self.user.wishlist.works.all().count(), 1)
|
||||||
|
|
||||||
|
# test the work page
|
||||||
|
r = self.client.get("/work/1/")
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
anon_client = Client()
|
||||||
|
r = anon_client.get("/work/1/")
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
# remove the book
|
# remove the book
|
||||||
r = self.client.post("/wishlist/", {"remove_work_id": "1"},
|
r = self.client.post("/wishlist/", {"remove_work_id": "1"},
|
||||||
HTTP_X_REQUESTED_WITH="XMLHttpRequest")
|
HTTP_X_REQUESTED_WITH="XMLHttpRequest")
|
||||||
self.assertEqual(self.user.wishlist.works.all().count(), 0)
|
self.assertEqual(self.user.wishlist.works.all().count(), 0)
|
||||||
|
|
||||||
class SupporterPage(TestCase):
|
class PageTests(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.user = User.objects.create_user('test', 'test@example.org', 'test')
|
self.user = User.objects.create_user('test', 'test@example.org', 'test')
|
||||||
|
self.user = User.objects.create_user('test_other', 'test@example.org', 'test_other')
|
||||||
self.client = Client()
|
self.client = Client()
|
||||||
self.client.login(username='test', password='test')
|
self.client.login(username='test', password='test')
|
||||||
|
|
||||||
def test_view_by_anonymous(self):
|
def test_view_by_self(self):
|
||||||
# logged in
|
# logged in
|
||||||
r = self.client.get("/supporter/test/")
|
r = self.client.get("/supporter/test/")
|
||||||
self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_view_by_other(self):
|
||||||
|
# someone else's supporter page
|
||||||
|
r = self.client.get("/supporter/test_other/")
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
|
def test_view_by_anonymous(self):
|
||||||
# not logged in
|
# not logged in
|
||||||
anon_client = Client()
|
anon_client = Client()
|
||||||
r = self.client.get("/supporter/test/")
|
r = anon_client.get("/supporter/test/")
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
r = anon_client.get("/")
|
||||||
self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
class GoogleBooksTest(TestCase):
|
class GoogleBooksTest(TestCase):
|
||||||
|
|
Loading…
Reference in New Issue