Advertisement
Guest User

Untitled

a guest
Oct 13th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 23.73 KB | None | 0 0
  1. e
  2. from django.core.urlresolvers import reverse
  3.  
  4. from .models import GreenspaceUser, Patient, Therapist, Clinic
  5. from .forms import (ModifyProfilePatientForm,
  6.                     ModifyProfileTherapistForm,
  7.                     ModifyProfileClinicForm,
  8.                     SecurityQuestionUpdateForm,
  9.                     CompleteProfileClinicForm,
  10.                     CompleteProfileTherapistForm,
  11.                     CompleteProfilePatientForm,
  12.                     CompleteProfilePatientWithTherapistForm)
  13.  
  14. PATIENT_EMAIL = "patient@grnspace.co"
  15. PATIENT_FIRST_NAME = "Elon"
  16. PATIENT_LAST_NAME = "Musk"
  17. PATIENT_PASSWORD = "password"
  18. PATIENT_SECRET_ANSWER = "some answer"
  19. THERAPIST_EMAIL = "therapist@grnspace.co"
  20. THERAPIST_FIRST_NAME = "Steve"
  21. THERAPIST_LAST_NAME = "Jobs"
  22. THERAPIST_PASSWORD = "password"
  23. THERAPIST_SECRET_ANSWER = "some answer"
  24. CLINIC_EMAIL = "clinic@grnspace.co"
  25. CLINIC_FIRST_NAME = "Better"
  26. CLINIC_LAST_NAME = "Clinic"
  27. CLINIC_PASSWORD = "password"
  28. CLINIC_SECRET_ANSWER = "some answer"
  29.  
  30. class TestViews(TestCase):
  31.  
  32.     def setUp(self):
  33.         # Set up patient and therapist user accounts
  34.         patient_user = GreenspaceUser.objects.create_user(
  35.             PATIENT_EMAIL, PATIENT_FIRST_NAME, PATIENT_LAST_NAME, PATIENT_PASSWORD,
  36.             user_type = GreenspaceUser.USER_TYPE_PATIENT)
  37.         self._patient = Patient.objects.create(user=patient_user, secret_answer=PATIENT_SECRET_ANSWER)
  38.  
  39.         therapist_user = GreenspaceUser.objects.create_user(
  40.             THERAPIST_EMAIL, THERAPIST_FIRST_NAME, THERAPIST_LAST_NAME, THERAPIST_PASSWORD,
  41.             user_type = GreenspaceUser.USER_TYPE_THERAPIST)
  42.         self._therapist = Therapist.objects.create(user=therapist_user, secret_answer=THERAPIST_SECRET_ANSWER)
  43.  
  44.         clinic_user = GreenspaceUser.objects.create_user(
  45.             CLINIC_EMAIL, CLINIC_FIRST_NAME, CLINIC_LAST_NAME, CLINIC_PASSWORD,
  46.             user_type = GreenspaceUser.USER_TYPE_CLINIC)
  47.         self._clinic = Clinic.objects.create(user=clinic_user, secret_answer=CLINIC_SECRET_ANSWER)
  48.  
  49.         self._patient.therapist = self._therapist
  50.         self._patient.save()
  51.         self._therapist.clinic = self._clinic
  52.         self._therapist.save()
  53.  
  54.     def tearDown(self):
  55.         self.client.logout()
  56.  
  57.     # Method used to store a variable number of patients and therapists inside a clinic
  58.     def addToClinic(self, amount):
  59.         for i in range(amount):
  60.             NEXT_THERAPIST_EMAIL = str(i) + "therapist@grnspace.co" # concatenate to avoid duplicates
  61.             NEXT_THERAPIST_FIRST_NAME = chr(i + ord('A')) + "Richard" # concatenate for ordering when paginated
  62.             NEXT_THERAPIST_LAST_NAME = chr(i + ord('A')) + "Hendricks" # concatenate for ordering when paginated
  63.             NEXT_THERAPIST_PASSWORD = "password"
  64.             NEXT_THERAPIST_SECRET_ANSWER = "some answer"
  65.  
  66.             NEXT_PATIENT_EMAIL = str(i) + "patient@grnspace.co"
  67.             NEXT_PATIENT_FIRST_NAME = chr(i + ord('A')) + "Erlich"
  68.             NEXT_PATIENT_LAST_NAME = chr(i + ord('A')) + "Bachmann"
  69.             NEXT_PATIENT_PASSWORD = "password"
  70.             NEXT_PATIENT_SECRET_ANSWER = "some answer"
  71.  
  72.             next_therapist_user = GreenspaceUser.objects.create_user(
  73.                 NEXT_THERAPIST_EMAIL, NEXT_THERAPIST_FIRST_NAME, NEXT_THERAPIST_LAST_NAME, NEXT_THERAPIST_PASSWORD,
  74.                 user_type = GreenspaceUser.USER_TYPE_THERAPIST)
  75.             self.next_therapist = Therapist.objects.create(user=next_therapist_user, secret_answer=NEXT_THERAPIST_SECRET_ANSWER)
  76.  
  77.             next_patient_user = GreenspaceUser.objects.create_user(
  78.                 NEXT_PATIENT_EMAIL, NEXT_PATIENT_FIRST_NAME, NEXT_PATIENT_LAST_NAME, NEXT_PATIENT_PASSWORD,
  79.                 user_type = GreenspaceUser.USER_TYPE_PATIENT)
  80.             self.next_patient = Patient.objects.create(user=next_patient_user, secret_answer=NEXT_PATIENT_SECRET_ANSWER)
  81.  
  82.             self.next_patient.therapist = self.next_therapist
  83.             self.next_patient.save()
  84.             self.next_therapist.clinic = self._clinic
  85.             self.next_therapist.save()
  86.  
  87.     def test_profile_detail_view_no_auth(self):
  88.         response = self.client.get(reverse("profile"))
  89.         self.assertEqual(response.status_code, 302)
  90.         self.assertRedirects(response, '/login/?next=/accounts/profile/')
  91.  
  92.     def test_profile_detail_view_patient_incomplete_profile(self):
  93.         self.client.force_login(self._patient.user)
  94.         response = self.client.get(reverse("profile"))
  95.         self.assertEqual(response.status_code, 302)
  96.         self.assertRedirects(response, '/complete_profile/', target_status_code=302)
  97.  
  98.     def test_profile_detail_view_patient(self):
  99.         self._patient.profile_completed = True
  100.         self._patient.save()
  101.         self.client.force_login(self._patient.user)
  102.         response = self.client.get(reverse("profile"))
  103.         self.assertEqual(response.status_code, 200)
  104.         self.assertTemplateUsed(template_name='profile/detail_patient.html')
  105.         self.assertEqual(response.context['profile'], self._patient)
  106.  
  107.     def test_profile_detail_view_therapist_incomplete_profile(self):
  108.         self.client.force_login(self._therapist.user)
  109.         response = self.client.get(reverse("profile"))
  110.         self.assertEqual(response.status_code, 302)
  111.         self.assertRedirects(response, '/complete_profile/', target_status_code=302)
  112.  
  113.     def test_profile_detail_view_therapist(self):
  114.         self._therapist.profile_completed = True
  115.         self._therapist.save()
  116.         self.client.force_login(self._therapist.user)
  117.         response = self.client.get(reverse("profile"))
  118.         self.assertEqual(response.status_code, 200)
  119.         self.assertTemplateUsed(template_name='profile/detail_therapist.html')
  120.         self.assertEqual(response.context['profile'], self._therapist)
  121.  
  122.     def test_profile_detail_view_clinic_incomplete_profile(self):
  123.         self.client.force_login(self._clinic.user)
  124.         response = self.client.get(reverse("profile"))
  125.         self.assertEqual(response.status_code, 302)
  126.         self.assertRedirects(response, '/complete_profile/', target_status_code=302)
  127.  
  128.     def test_profile_detail_view_clinic(self):
  129.         self._clinic.profile_completed = True
  130.         self._clinic.save()
  131.         self.client.force_login(self._clinic.user)
  132.         response = self.client.get(reverse("profile"))
  133.         self.assertEqual(response.status_code, 200)
  134.         self.assertTemplateUsed(template_name='profile/detail_clinic.html')
  135.         self.assertEqual(response.context['profile'], self._clinic)
  136.  
  137.     def test_modify_profile_patient_view_no_auth(self):
  138.         response = self.client.get(reverse("modify_profile_patient"))
  139.         self.assertEqual(response.status_code, 302)
  140.         self.assertRedirects(response, '/login/?next=/accounts/modify_profile/')
  141.  
  142.     def test_modify_profile_patient_view(self):
  143.         self._patient.profile_completed = True
  144.         self._patient.save()
  145.         self.client.force_login(self._patient.user)
  146.         response = self.client.get(reverse("modify_profile_patient"))
  147.  
  148.         # GET request
  149.         self.assertEqual(response.status_code, 200)
  150.         self.assertTemplateUsed(template_name='profile/modify.html')
  151.         self.assertIsInstance(response.context["form"], ModifyProfilePatientForm)
  152.  
  153.         # POST request with no data
  154.         response = self.client.post(reverse("modify_profile_patient"), {})
  155.         self.assertEqual(response.status_code, 200)
  156.         self.assertContains(response, "This field is required.")
  157.  
  158.         # POST request with data
  159.         response = self.client.post(reverse("modify_profile_patient"),
  160.             {
  161.                 "phone": "416-123-4567",
  162.                 "year_of_birth": "1980",
  163.                 "gender": "F",
  164.                 "profession": "Manufacturing",
  165.                 "mobile_phone": "1-416-123-4567",
  166.                 "sms_pref": "True"
  167.             })
  168.         self.assertEqual(response.status_code, 302)
  169.         self.assertRedirects(response, '/accounts/profile/')
  170.  
  171.     def test_modify_profile_therapist_view(self):
  172.         self._therapist.profile_completed = True
  173.         self._therapist.save()
  174.         self.client.force_login(self._therapist.user)
  175.  
  176.         # GET request
  177.         response = self.client.get(reverse("modify_profile_therapist"))
  178.         self.assertEqual(response.status_code, 200)
  179.         self.assertTemplateUsed(template_name='profile/modify.html')
  180.         self.assertIsInstance(response.context["form"], ModifyProfileTherapistForm)
  181.         self.assertContains(response, "Name to show patients")
  182.  
  183.         # POST request with no data
  184.         response = self.client.post(reverse("modify_profile_therapist"), {})
  185.         self.assertEqual(response.status_code, 200)
  186.         self.assertContains(response, "This field is required.")
  187.  
  188.         # POST request with data
  189.         response = self.client.post(reverse("modify_profile_therapist"),
  190.             {
  191.                 "display_name": "Display Name",
  192.                 "phone": "416-123-4567",
  193.                 "address_line_1": "123 Yonge St",
  194.                 "address_line_2": "Unit 111",
  195.                 "address_city": "Toronto",
  196.                 "address_province": "ON",
  197.                 "therapist_type": "PSYCHIATRIST",
  198.                 "province_of_registration": "ON",
  199.                 "regulatory_body":"abc",
  200.                 "registration_number": "666",
  201.             })
  202.         self.assertEqual(response.status_code, 302)
  203.         self.assertRedirects(response, '/accounts/profile/')
  204.  
  205.     def test_modify_profile_clinic_view(self):
  206.         self._clinic.profile_completed = True
  207.         self._clinic.save()
  208.         self.client.force_login(self._clinic.user)
  209.  
  210.         # GET request
  211.         response = self.client.get(reverse("modify_profile_clinic"))
  212.         self.assertEqual(response.status_code, 200)
  213.         self.assertTemplateUsed(template_name='profile/modify.html')
  214.         self.assertIsInstance(response.context["form"], ModifyProfileClinicForm)
  215.         self.assertContains(response, "Clinic name")
  216.  
  217.         # POST request with no data
  218.         response = self.client.post(reverse("modify_profile_clinic"), {})
  219.         self.assertEqual(response.status_code, 200)
  220.         self.assertContains(response, "This field is required.")
  221.  
  222.         # POST request with data
  223.         response = self.client.post(reverse("modify_profile_clinic"),
  224.             {
  225.                 "display_name": "Display Name",
  226.                 "phone": "416-123-4567",
  227.                 "address_line_1": "123 Yonge St",
  228.                 "address_line_2": "Unit 111",
  229.                 "address_city": "Toronto",
  230.                 "address_province": "ON",
  231.                 "therapist_type_other": "Other type"
  232.             })
  233.         self.assertEqual(response.status_code, 302)
  234.         self.assertRedirects(response, '/accounts/profile/')
  235.  
  236.     def test_change_security_question_view_no_auth(self):
  237.         response = self.client.get(reverse("security_question_change"))
  238.         self.assertEqual(response.status_code, 302)
  239.         self.assertRedirects(response, '/login/?next=/accounts/security_question_change/')
  240.  
  241.     def test_change_security_question_view_patient(self):
  242.         self._patient.profile_completed = True
  243.         self._patient.save()
  244.         self.client.force_login(self._patient.user)
  245.  
  246.         # GET request
  247.         response = self.client.get(reverse("security_question_change"))
  248.         self.assertEqual(response.status_code, 200)
  249.         self.assertTemplateUsed(template_name='profile/modify_security_question.html')
  250.         self.assertIsInstance(response.context["form"], SecurityQuestionUpdateForm)
  251.         self.assertContains(response, "Change your security question")
  252.  
  253.         # POST request with no data
  254.         response = self.client.post(reverse("security_question_change"), {})
  255.         self.assertEqual(response.status_code, 200)
  256.         self.assertContains(response, "This field is required.")
  257.  
  258.         # POST request with data
  259.         response = self.client.post(reverse("security_question_change"),
  260.             {
  261.                 "answer": PATIENT_SECRET_ANSWER,
  262.                 "new_security_question": "COUSIN",
  263.                 "new_answer1": "New answer",
  264.                 "new_answer2": "New answer",
  265.             })
  266.         self.assertEqual(response.status_code, 302)
  267.         self.assertRedirects(response, '/accounts/profile/')
  268.  
  269.     def test_change_security_question_view_therapist(self):
  270.         self._therapist.profile_completed = True
  271.         self._therapist.save()
  272.         self.client.force_login(self._therapist.user)
  273.  
  274.         # GET request
  275.         response = self.client.get(reverse("security_question_change"))
  276.         self.assertEqual(response.status_code, 200)
  277.         self.assertTemplateUsed(template_name='profile/modify_security_question.html')
  278.         self.assertIsInstance(response.context["form"], SecurityQuestionUpdateForm)
  279.         self.assertContains(response, "Change your security question")
  280.  
  281.         # POST request with no data
  282.         response = self.client.post(reverse("security_question_change"), {})
  283.         self.assertEqual(response.status_code, 200)
  284.         self.assertContains(response, "This field is required.")
  285.  
  286.         # POST request with data
  287.         response = self.client.post(reverse("security_question_change"),
  288.             {
  289.                 "answer": THERAPIST_SECRET_ANSWER,
  290.                 "new_security_question": "COUSIN",
  291.                 "new_answer1": "New answer",
  292.                 "new_answer2": "New answer",
  293.             })
  294.         self.assertEqual(response.status_code, 302)
  295.         self.assertRedirects(response, '/accounts/profile/')
  296.  
  297.     def test_change_security_question_view_clinic(self):
  298.         self._clinic.profile_completed = True
  299.         self._clinic.save()
  300.         self.client.force_login(self._clinic.user)
  301.  
  302.         # GET request
  303.         response = self.client.get(reverse("security_question_change"))
  304.         self.assertEqual(response.status_code, 200)
  305.         self.assertTemplateUsed(template_name='profile/modify_security_question.html')
  306.         self.assertIsInstance(response.context["form"], SecurityQuestionUpdateForm)
  307.         self.assertContains(response, "Change your security question")
  308.  
  309.         # POST request with no data
  310.         response = self.client.post(reverse("security_question_change"), {})
  311.         self.assertEqual(response.status_code, 200)
  312.         self.assertContains(response, "This field is required.")
  313.  
  314.         # POST request with data
  315.         response = self.client.post(reverse("security_question_change"),
  316.             {
  317.                 "answer": CLINIC_SECRET_ANSWER,
  318.                 "new_security_question": "COUSIN",
  319.                 "new_answer1": "New answer",
  320.                 "new_answer2": "New answer",
  321.             })
  322.         self.assertEqual(response.status_code, 302)
  323.         self.assertRedirects(response, '/accounts/profile/')
  324.  
  325.     def test_complete_profile_patient_view_no_auth(self):
  326.         response = self.client.get(reverse("profile_completion_patient"))
  327.         self.assertEqual(response.status_code, 302)
  328.         self.assertRedirects(response, '/login/?next=/accounts/complete_my_profile/')
  329.  
  330.     def test_complete_profile_patient_view(self):
  331.         self.client.force_login(self._patient.user)
  332.  
  333.         # GET request
  334.         response = self.client.get(reverse("profile_completion_patient"))
  335.         self.assertEqual(response.status_code, 200)
  336.         self.assertTemplateUsed(template_name='profile/complete_patient_without_therapist.html')
  337.         self.assertIsInstance(response.context["form"], CompleteProfilePatientForm)
  338.         self.assertContains(response, "Complete your registration")
  339.  
  340.         # POST request with no data
  341.         response = self.client.post(reverse("profile_completion_patient"), {})
  342.         self.assertEqual(response.status_code, 200)
  343.         self.assertContains(response, "This field is required.")
  344.  
  345.         # POST request with data
  346.         response = self.client.post(reverse("profile_completion_patient"),
  347.             {
  348.                 "gender": "F",
  349.                 "profession": "Manufacturing",
  350.                 "phone": "416-123-4567",
  351.                 "therapist_name": "Doctor Doc",
  352.                 "therapist_phone": "416-537-5592",
  353.                 "diagnosed_in_past_bool": "F",
  354.                 "diagnosed_before_year_bool": "F",
  355.                 "therapy_in_past_bool": "F",
  356.                 "therapy_in_past_utility": "F",
  357.                 "secret_question": "MOTHER",
  358.                 "secret_answer": "abcde",
  359.             })
  360.         self.assertEqual(response.status_code, 302)
  361.         self.assertRedirects(response, '/after_login/', target_status_code=302)
  362.  
  363.     def test_complete_profile_patient_with_therapist_view_no_auth(self):
  364.         response = self.client.get(reverse("profile_completion_patient_with_therapist"))
  365.         self.assertEqual(response.status_code, 302)
  366.         self.assertRedirects(response, '/login/?next=/accounts/complete_profile/')
  367.  
  368.     def test_complete_profile_patient_with_therapist_view(self):
  369.         self.client.force_login(self._patient.user)
  370.  
  371.         # GET request
  372.         response = self.client.get(reverse("profile_completion_patient_with_therapist"))
  373.         self.assertEqual(response.status_code, 200)
  374.         self.assertTemplateUsed(template_name='profile/complete_patient.html')
  375.         self.assertIsInstance(response.context["form"], CompleteProfilePatientWithTherapistForm)
  376.         self.assertContains(response, "Complete your registration")
  377.  
  378.         # POST request with no data
  379.         response = self.client.post(reverse("profile_completion_patient_with_therapist"), {})
  380.         self.assertEqual(response.status_code, 200)
  381.         self.assertContains(response, "This field is required.")
  382.  
  383.         response = self.client.post(reverse("profile_completion_patient_with_therapist"),
  384.             {
  385.                 "gender": "F",
  386.                 "profession": "Manufacturing",
  387.                 "phone": "416-123-4567",
  388.                 "diagnosed_in_past_bool": "F",
  389.                 "diagnosed_before_year_bool": "F",
  390.                 "therapy_in_past_bool": "F",
  391.                 "therapy_in_past_utility": "F",
  392.                 "secret_question": "MOTHER",
  393.                 "secret_answer": "abcde",
  394.             })
  395.         self.assertEqual(response.status_code, 302)
  396.         self.assertRedirects(response, '/after_login/', target_status_code=302)
  397.  
  398.     def test_complete_profile_therapist_view_no_auth(self):
  399.         response = self.client.get(reverse("profile_completion_therapist"))
  400.         self.assertEqual(response.status_code, 302)
  401.         self.assertRedirects(response, '/login/?next=/accounts/complete_therapist_profile/')
  402.  
  403.     def test_complete_profile_therapist_view(self):
  404.         self.client.force_login(self._therapist.user)
  405.  
  406.         # GET request
  407.         response = self.client.get(reverse("profile_completion_therapist"))
  408.         self.assertEqual(response.status_code, 200)
  409.         self.assertTemplateUsed(template_name='profile/complete_therapist.html')
  410.         self.assertIsInstance(response.context["form"], CompleteProfileTherapistForm)
  411.         self.assertContains(response, "Complete your registration")
  412.  
  413.         # POST request with no data
  414.         response = self.client.post(reverse("profile_completion_therapist"), {})
  415.         self.assertEqual(response.status_code, 200)
  416.         self.assertContains(response, "This field is required.")
  417.  
  418.         # POST request with data
  419.         response = self.client.post(reverse("profile_completion_therapist"),
  420.             {
  421.                 "display_name": "Therapist name",
  422.                 "phone": "1416-123-4567",
  423.                 "address_line_1": "Address",
  424.                 "address_line_2": "Address",
  425.                 "address_city": "Toronto",
  426.                 "address_province": "ON",
  427.                 "therapist_type": "SOCIAL_WORKER",
  428.                 "province_of_registration": "ON",
  429.                 "regulatory_body":"abc",
  430.                 "registration_number": "666",
  431.                 "secret_question": "MOTHER",
  432.                 "secret_answer": "abcde",
  433.             })
  434.         self.assertEqual(response.status_code, 302)
  435.         self.assertRedirects(response, '/after_login/', target_status_code=302)
  436.  
  437.     def test_complete_profile_clinic_view_no_auth(self):
  438.         response = self.client.get(reverse("profile_completion_clinic"))
  439.         self.assertEqual(response.status_code, 302)
  440.         self.assertRedirects(response, '/login/?next=/accounts/complete_clinic_profile/')
  441.  
  442.     def test_complete_profile_clinic_view(self):
  443.         self.client.force_login(self._clinic.user)
  444.  
  445.         # GET request
  446.         response = self.client.get(reverse("profile_completion_clinic"))
  447.         self.assertEqual(response.status_code, 200)
  448.         self.assertTemplateUsed(template_name='profile/complete.html')
  449.         self.assertIsInstance(response.context["form"], CompleteProfileClinicForm)
  450.         self.assertContains(response, "Complete your registration")
  451.  
  452.         # POST request with no data
  453.         response = self.client.post(reverse("profile_completion_clinic"), {})
  454.         self.assertEqual(response.status_code, 200)
  455.         self.assertContains(response, "This field is required.")
  456.  
  457.         # POST request with data
  458.         response = self.client.post(reverse("profile_completion_clinic"),
  459.             {
  460.                 "display_name": "Clinic name",
  461.                 "phone": "1416-123-4567",
  462.                 "address_line_1": "Address",
  463.                 "address_line_2": "Address",
  464.                 "address_city": "Toronto",
  465.                 "address_province": "ON",
  466.                 "therapist_type_other": "Other type",
  467.                 "secret_question": "MOTHER",
  468.                 "secret_answer": "abcde",
  469.             })
  470.         self.assertEqual(response.status_code, 302)
  471.         self.assertRedirects(response, '/after_login/', target_status_code=302)
  472.  
  473.     def test_therapist_list_clinic_view(self):
  474.         self.client.force_login(self._clinic.user)
  475.         self.addToClinic(3)
  476.  
  477.         # GET request
  478.         response = self.client.get(reverse("therapist_list", kwargs={"pk": self._clinic.pk}))
  479.         import pdb; pdb.set_trace()
  480.         self.assertEqual(response.status_code, 302) #deal with this code
  481.         self.assertTemplateUsed(template_name='profile/therapist_list.html')
  482.         self.assertContains(response, "Therapists")
  483.  
  484.         # GET request with random search
  485.         response = self.client.get(reverse("therapist_list", {"q":"qwerty"}, kwargs={"pk": self._clinic.pk}))
  486.         self.assertEqual(response.status_code, 200)
  487.         self.assertContains(response, "0 therapists found matching qwerty")
  488.  
  489.         # GET request with valid search
  490.         response = self.client.get(reverse("therapist_list", {"q":"Jobs"}, kwargs={"pk": self._clinic.pk}))
  491.         self.assertEqual(response.status_code, 200)
  492.         self.assertContains(response, "1 therapist found matching Jobs")
  493.  
  494.     def test_master_patient_list_clinic_view(self):
  495.         self.client.force_login(self._clinic.user)
  496.  
  497.         # GET request
  498.         response = self.client.get(reverse("master_patient_list", kwargs={"pk": self._clinic.pk}))
  499.         self.assertEqual(response.status_code, 302) #deal with this code
  500.         self.assertTemplateUsed(template_name='profile/master_patient_list.html')
  501.         self.assertContains(response, "Patients")
  502.  
  503.         # GET request with random search
  504.         response = self.client.get(reverse("master_patient_list", {"q":"qwerty"}, kwargs={"pk": self._clinic.pk}))
  505.         self.assertEqual(response.status_code, 200)
  506.         self.assertContains(response, "0 patients found matching qwerty")
  507.  
  508.         # GET request with valid search
  509.         response = self.client.get(reverse("master_patient_list", {"q":"Elon"}, kwargs={"pk": self._clinic.pk}))
  510.         self.assertEqual(response.status_code, 200)
  511.         self.assertContains(response, "1 patient found matching Elon")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement