Commit 9e0ef1e2 authored by Daniel W Bond's avatar Daniel W Bond

removed duplicated code in housing view tests by creating client_login()

parent 5b84efff
......@@ -30,6 +30,13 @@ class HousingViewTest(TestCase):
gmason = Student.objects.create(user=user)
gmason.save()
def client_login(self):
client = Client()
gmason = User.objects.get(username='gmason')
# this is only for testing purposes; we're using CAS for auth
client.login(username='gmason', password='eagle_bank')
return client
class ListBuildingsTest(TestCase):
......@@ -44,10 +51,7 @@ class ListBuildingsTest(TestCase):
class DetailBuildingTest(HousingViewTest):
def test_detail_building_ok(self):
client = Client()
gmason = User.objects.get(username='gmason')
# this is only for testing purposes; we're using CAS for auth
client.login(username='gmason', password='eagle_bank')
client = self.client_login()
response = client.get(reverse('detail_building',
kwargs = {'building': 'wilson'}))
self.assertEqual(response.status_code, 200)
......@@ -56,9 +60,7 @@ class DetailBuildingTest(HousingViewTest):
class DetailFloorTest(HousingViewTest):
def test_detail_floor_ok(self):
client = Client()
gmason = User.objects.get(username='gmason')
client.login(username='gmason', password='eagle_bank')
client = self.client_login()
response = client.get(reverse('detail_floor',
kwargs = {'building': 'wilson',
'floor': '3'}))
......@@ -68,9 +70,7 @@ class DetailFloorTest(HousingViewTest):
class DetailRoomTest(HousingViewTest):
def test_detail_room_ok(self):
client = Client()
gmason = User.objects.get(username='gmason')
client.login(username='gmason', password='eagle_bank')
client = self.client_login()
response = client.get(reverse('detail_room',
kwargs = {'building': 'wilson',
'floor': '3',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment