Commits

Luke Plant committed 433e8cf

Small test cleanup

Comments (0)

Files changed (1)

cciw/bookings/tests.py

 from cciw.sitecontent.models import HtmlChunk
 
 
+DISABLED_BOOK_NOW_BTN = "id_book_now_btn\" disabled>"
+ENABLED_BOOK_NOW_BUTTON = "id_book_now_btn\">"
+
 class CreateCampMixin(object):
 
     camp_minimum_age = 11
         self.assertContains(resp, "Joe Bloggs")
         self.assertContains(resp, "£100")
         self.assertContains(resp, "This place can be booked")
-        self.assertContains(resp, "id_book_now_btn\">")
+        self.assertContains(resp, ENABLED_BOOK_NOW_BUTTON)
 
     def test_handle_custom_price(self):
         self.login()
         self.assertContains(resp, "Joe Bloggs")
         self.assertContains(resp, "TBA")
         self.assertContains(resp, "A custom discount needs to be arranged by the booking secretary")
-        self.assertContains(resp, "id_book_now_btn\" disabled>")
+        self.assertContains(resp, DISABLED_BOOK_NOW_BTN)
         self.assertContains(resp, "This place cannot be booked for the reasons described above")
 
     def test_2nd_child_discount_allowed(self):
 
         resp = self.client.get(self.url)
         self.assertContains(resp, "You cannot use a 2nd child discount")
-        self.assertContains(resp, "id_book_now_btn\" disabled>")
+        self.assertContains(resp, DISABLED_BOOK_NOW_BTN)
 
         # 2 places, both at 2nd child discount, is not allowed.
         self.create_place({'price_type': PRICE_2ND_CHILD})
 
         resp = self.client.get(self.url)
         self.assertContains(resp, "You cannot use a 2nd child discount")
-        self.assertContains(resp, "id_book_now_btn\" disabled>")
+        self.assertContains(resp, DISABLED_BOOK_NOW_BTN)
 
     def test_3rd_child_discount_allowed(self):
         self.login()
 
         resp = self.client.get(self.url)
         self.assertContains(resp, "You cannot use a 3rd child discount")
-        self.assertContains(resp, "id_book_now_btn\" disabled>")
+        self.assertContains(resp, DISABLED_BOOK_NOW_BTN)
 
         # 3 places, with 2 at 3rd child discount, is not allowed.
         self.create_place({'price_type': PRICE_3RD_CHILD})
 
         resp = self.client.get(self.url)
         self.assertContains(resp, "You cannot use a 3rd child discount")
-        self.assertContains(resp, "id_book_now_btn\" disabled>")
+        self.assertContains(resp, DISABLED_BOOK_NOW_BTN)
 
     def test_handle_serious_illness(self):
         self.login()
 
         resp = self.client.get(self.url)
         self.assertContains(resp, "Must be approved by leader due to serious illness/condition")
-        self.assertContains(resp, "id_book_now_btn\" disabled>")
+        self.assertContains(resp, DISABLED_BOOK_NOW_BTN)
 
     def test_minimum_age(self):
         self.login()
         self.create_place({'sex':'m'})
         resp = self.client.get(self.url)
         self.assertContains(resp, "There are no places left on this camp")
-        self.assertContains(resp, "id_book_now_btn\" disabled>")
+        self.assertContains(resp, DISABLED_BOOK_NOW_BTN)
 
         # Don't want a redundant message
         self.assertNotContains(resp, "There are no places left for boys")
         self.create_place({'sex':'m'})
         resp = self.client.get(self.url)
         self.assertContains(resp, "There are no places left for boys")
-        self.assertContains(resp, "id_book_now_btn\" disabled>")
+        self.assertContains(resp, DISABLED_BOOK_NOW_BTN)
 
         # Check that we can still book female places
         Booking.objects.filter(state=BOOKING_INFO_COMPLETE).delete()
         self.create_place({'sex':'f'})
         resp = self.client.get(self.url)
         self.assertNotContains(resp, "There are no places left")
-        self.assertContains(resp, "id_book_now_btn\">")
+        self.assertContains(resp, ENABLED_BOOK_NOW_BUTTON)
 
     def test_no_female_places_left(self):
         self.login()
         self.create_place({'sex':'f'})
         resp = self.client.get(self.url)
         self.assertContains(resp, "There are no places left for girls")
-        self.assertContains(resp, "id_book_now_btn\" disabled>")
+        self.assertContains(resp, DISABLED_BOOK_NOW_BTN)
 
     def test_not_enough_places_left(self):
         self.login()
         self.create_place({'sex':'f'})
         resp = self.client.get(self.url)
         self.assertContains(resp, "There are not enough places left on this camp")
-        self.assertContains(resp, "id_book_now_btn\" disabled>")
+        self.assertContains(resp, DISABLED_BOOK_NOW_BTN)
 
     def test_not_enough_male_places_left(self):
         self.login()
         self.create_place({'sex':'m'})
         resp = self.client.get(self.url)
         self.assertContains(resp, "There are not enough places for boys left on this camp")
-        self.assertContains(resp, "id_book_now_btn\" disabled>")
+        self.assertContains(resp, DISABLED_BOOK_NOW_BTN)
 
     def test_not_enough_female_places_left(self):
         self.login()
         self.create_place({'sex':'f'})
         resp = self.client.get(self.url)
         self.assertContains(resp, "There are not enough places for girls left on this camp")
-        self.assertContains(resp, "id_book_now_btn\" disabled>")
+        self.assertContains(resp, DISABLED_BOOK_NOW_BTN)
 
     def test_handle_two_problem_bookings(self):
         # Test the error we get for more than one problem booking
         self.assertContains(resp, "Joe Bloggs")
         self.assertContains(resp, "TBA")
         self.assertContains(resp, "A custom discount needs to be arranged by the booking secretary")
-        self.assertContains(resp, "id_book_now_btn\" disabled>")
+        self.assertContains(resp, DISABLED_BOOK_NOW_BTN)
         self.assertContains(resp, "These places cannot be booked for the reasons described above")
 
     def test_handle_mixed_problem_and_non_problem(self):
         resp = self.client.get(self.url)
         self.assertEqual(200, resp.status_code)
 
-        self.assertContains(resp, "id_book_now_btn\" disabled>")
+        self.assertContains(resp, DISABLED_BOOK_NOW_BTN)
         self.assertContains(resp, "One or more of the places cannot be booked")
 
     def test_total(self):
         self.assertContains(resp, "Another Child")
         self.assertContains(resp, "£0.01")
 
-        self.assertContains(resp, "id_book_now_btn\">")
+        self.assertContains(resp, ENABLED_BOOK_NOW_BUTTON)
         # Total:
         self.assertContains(resp, "£100.01")