def test_user_get_health_professional_with_health_professional(self):
        request = self.factory.get(
            'user/editpasswordhealthprofessional/(?P<email>[\w|\W]+)')
        request.user = self.health_professional

        with self.assertRaises(PermissionDenied):
            UpdateUserPassword.edit_health_professional_password_view(
                request, email='*****@*****.**')
    def test_user_post_health_professional_with_user(self):
        request = self.factory.post(
            'user/editpasswordhealthprofessional/(?P<email>[\w|\W]+)')
        request.user = self.user

        with self.assertRaises(PermissionDenied):
            UpdateUserPassword.edit_health_professional_password_view(
                request, email=self.health_professional.email)
    def test_user_post_patient_with_user(self):
        request = self.factory.post(
            'user/editpasswordpatient/(?P<email>[\w|\W]+)')
        request.user = self.user

        with self.assertRaises(PermissionDenied):
            UpdateUserPassword.edit_patient_password_view(
                request, email=self.patient.email)
    def test_user_edit_patient_with_patient(self):
        request = self.factory.get(
            'user/editpasswordpatient/(?P<email>[\w|\W]+)')
        request.user = self.patient

        with self.assertRaises(PermissionDenied):
            UpdateUserPassword.edit_patient_password_view(
                request, email='*****@*****.**')
    def test_user_post_health_professional_with_own_health_professional(self):
        request = self.factory.post(
            'user/editpasswordhealthprofessional/(?P<email>[\w|\W]+)')
        request.user = self.health_professional

        response = UpdateUserPassword.edit_health_professional_password_view(
            request, email=self.health_professional.email)
        self.assertEqual(response.status_code, 200)
    def post_without_login(self):
        request = self.factory.post(
            'user/editpasswordhealthprofessional/(?P<email>[\w|\W]+)')
        request.user = AnonymousUser()

        response = UpdateUserPassword.edit_health_professional_password_view(
            request, email=self.health_professional.email)
        self.assertEqual(response.status_code, 302)
    def test_user_post_patient_with_own_patient(self):
        request = self.factory.post(
            'user/editpasswordpatient/(?P<email>[\w|\W]+)')
        request.user = self.patient

        response = UpdateUserPassword.edit_patient_password_view(
            request, email=self.patient.email)
        self.assertEqual(response.status_code, 200)
    def _without_login(self):
        request = self.factory.get(
            'user/editpasswordpatient/(?P<email>[\w|\W]+)')
        request.user = AnonymousUser()

        response = UpdateUserPassword.edit_patient_password_view(
            request, email=self.patient.email)
        self.assertEqual(response.status_code, 302)