def test_doctor_first_name(self):
        user = createUser('doctor1', '*****@*****.**', 'doctor')
        user.save()
        try:
            doctor1 = Doctor(user=user)
            doctor1.user.first_name = 'F'
            doctor1.registration_time = timezone.now()
            user.save()
            doctor1.save()
        except IntegrityError:
            return HttpResponseServerError()

        self.assertEqual(doctor1.user.first_name, 'F')
        self.client = Client()
        self.client.login(username="******", password='******')
        url = reverse('display_profile', args=[user.id])
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.context['user'].first_name, 'F')
        try:
            doctor1.user.first_name = 'G'
            user.save()
            #doctor1.save()
        except IntegrityError:
            return HttpResponseServerError()
        url = reverse('display_profile', args=[user.id])
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(doctor1.user.first_name,'G')
        self.assertEqual(response.context['user'].first_name, 'G')
示例#2
0
    def test_doctor_first_name(self):
        user = createUser('doctor1', '*****@*****.**', 'doctor')
        user.save()
        try:
            doctor1 = Doctor(user=user)
            doctor1.user.first_name = 'F'
            doctor1.registration_time = timezone.now()
            user.save()
            doctor1.save()
        except IntegrityError:
            return HttpResponseServerError()

        self.assertEqual(doctor1.user.first_name, 'F')
        self.client = Client()
        self.client.login(username="******", password='******')
        url = reverse('display_profile', args=[user.id])
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.context['user'].first_name, 'F')
        try:
            doctor1.user.first_name = 'G'
            user.save()
            #doctor1.save()
        except IntegrityError:
            return HttpResponseServerError()
        url = reverse('display_profile', args=[user.id])
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(doctor1.user.first_name, 'G')
        self.assertEqual(response.context['user'].first_name, 'G')
示例#3
0
 def test_doctor_comments(self):
     user = createUser('doctor1', '*****@*****.**', 'doctor')
     try:
         doctor1 = Doctor(user=user)
         doctor1.comments = 'commie'
         user.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(doctor1.comments, 'commie')
示例#4
0
 def test_doctor_phone(self):
     user = createUser('doctor1', '*****@*****.**', 'doctor')
     try:
         doctor1 = Doctor(user=user)
         doctor1.phone = '416'
         user.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(doctor1.phone, '416')
 def test_doctor_comments(self):
     user = createUser('doctor1', '*****@*****.**', 'doctor')
     try:
         doctor1 = Doctor(user=user)
         doctor1.comments = 'commie'
         user.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(doctor1.comments, 'commie')
 def test_doctor_phone(self):
     user = createUser('doctor1', '*****@*****.**', 'doctor')
     try:
         doctor1 = Doctor(user=user)
         doctor1.phone = '416'
         user.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(doctor1.phone, '416')
    def test_create_new_patient(self):
        user = createUser('doctor2', '*****@*****.**', 'doctorf')
        user.save()
        try:
            doctor1 = Doctor(user=user)
            doctor1.user.first_name = 'F'
            doctor1.registration_time = timezone.now()
            user.save()
            doctor1.save()
        except IntegrityError:
            return HttpResponseServerError()

        try:
            patient = Patient(
                first_name = "John",
                last_name = "Smith",
                gps_coordinates = "101010",
                address = "Yonge street",
                date_of_birth = "1999-06-10",
                phone = "646646646464",
                health_id = "324324234",
                gender = "Male",
                email = "*****@*****.**"
            )
            patient.save()
        except IntegrityError:
            return HttpResponseServerError()

        self.assertEqual(patient.first_name, "John")
        self.assertEqual(patient.last_name, "Smith")
        self.assertEqual(patient.gps_coordinates, "101010")
        self.assertEqual(patient.address, "Yonge street")
        self.assertEqual(patient.date_of_birth, "1999-06-10")
        self.assertEqual(patient.phone, "646646646464")
        self.assertEqual(patient.health_id, "324324234")
        self.assertEqual(patient.gender, "Male")
        self.assertEqual(patient.email, "*****@*****.**")

        self.client.login(username="******", password='******')
        url2 = reverse('display_patient', args=[patient.id])
        response = self.client.get(url2)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.context['firstName'], "John")
        self.assertEqual(response.context['viewer'], user)
        self.assertEqual(response.context['user'], user)
        self.assertEqual(response.context['lastName'], "Smith")
        self.assertEqual(response.context['gender'], "Male")
        self.assertEqual(response.context['date_of_birth'], datetime.date(1999, 06,10))
        self.assertEqual(response.context['gps_coordinates'], "101010")
        self.assertEqual(response.context['health_id'], "324324234")
        self.assertEqual(response.context['address'], "Yonge street")
        self.assertEqual(response.context['phone'], "646646646464")
        self.assertEqual(response.context['email'], "*****@*****.**")
示例#8
0
    def test_create_new_patient(self):
        user = createUser('doctor2', '*****@*****.**', 'doctorf')
        user.save()
        try:
            doctor1 = Doctor(user=user)
            doctor1.user.first_name = 'F'
            doctor1.registration_time = timezone.now()
            user.save()
            doctor1.save()
        except IntegrityError:
            return HttpResponseServerError()

        try:
            patient = Patient(first_name="John",
                              last_name="Smith",
                              gps_coordinates="101010",
                              address="Yonge street",
                              date_of_birth="1999-06-10",
                              phone="646646646464",
                              health_id="324324234",
                              gender="Male",
                              email="*****@*****.**")
            patient.save()
        except IntegrityError:
            return HttpResponseServerError()

        self.assertEqual(patient.first_name, "John")
        self.assertEqual(patient.last_name, "Smith")
        self.assertEqual(patient.gps_coordinates, "101010")
        self.assertEqual(patient.address, "Yonge street")
        self.assertEqual(patient.date_of_birth, "1999-06-10")
        self.assertEqual(patient.phone, "646646646464")
        self.assertEqual(patient.health_id, "324324234")
        self.assertEqual(patient.gender, "Male")
        self.assertEqual(patient.email, "*****@*****.**")

        self.client.login(username="******", password='******')
        url2 = reverse('display_patient', args=[patient.id])
        response = self.client.get(url2)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.context['firstName'], "John")
        self.assertEqual(response.context['viewer'], user)
        self.assertEqual(response.context['user'], user)
        self.assertEqual(response.context['lastName'], "Smith")
        self.assertEqual(response.context['gender'], "Male")
        self.assertEqual(response.context['date_of_birth'],
                         datetime.date(1999, 06, 10))
        self.assertEqual(response.context['gps_coordinates'], "101010")
        self.assertEqual(response.context['health_id'], "324324234")
        self.assertEqual(response.context['address'], "Yonge street")
        self.assertEqual(response.context['phone'], "646646646464")
        self.assertEqual(response.context['email'], "*****@*****.**")
示例#9
0
 def test_doctor_last_name(self):
     user = createUser('doctor1', '*****@*****.**', 'doctor')
     try:
         doctor1 = Doctor(user=user)
         doctor1.user.last_name = 'L'
         user.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(doctor1.user.last_name, 'L')
示例#10
0
def populate_default_test_data():
    ''' Populates the database with default test data. '''

    try:
        worker_user = createUser('theworker', '*****@*****.**', 'password')
        worker_user.save()
        worker = Worker(user=worker_user)
        worker.registration_time = timezone.now()
        worker.save()

    except IntegrityError:
        print 'Failed to create a default worker user'
        return HttpResponseServerError()

    try:
        doctor_user = createUser('thedoctor', '*****@*****.**', 'thepassword')
        doctor_user.save()
        doctor = Doctor(user=doctor_user)
        doctor.user_id = doctor_user.id
        doctor.registration_time = timezone.now()
        doctor.save()
    except IntegrityError:
        print 'Failed to create a default doctor'
        return HttpResponseServerError()

    try:
        doctor2_user = createUser('doctor2', '*****@*****.**', 'd2password')
        doctor2_user.save()
        doctor2 = Doctor(user=doctor2_user)
        doctor2.user_id = doctor2_user.id
        doctor2.registration_time = timezone.now()
        doctor2.save()
    except IntegrityError:
        print 'Failed to create a default doctor'
        return HttpResponseServerError()

    try:
        sample_patient = Patient(first_name="Alexis",
                                 last_name="Advantageous",
                                 gps_coordinates="101010",
                                 address="Yonge street",
                                 date_of_birth="1999-06-10",
                                 phone="646646646464",
                                 health_id="324324234",
                                 gender="Male",
                                 email="*****@*****.**")

        sample_patient.save()
    except IntegrityError:
        print 'Failed to create a default patient'
        return HttpResponseServerError()

    try:
        comment = Comment(author=worker_user,
                          text="Trololololol.",
                          time_posted=timezone.now())
        comment.save()
    except IntegrityError:
        print 'Failed to create a default comment'
        return HttpResponseServerError()

    try:
        comment_group = CommentGroup()
        comment_group.save()
        comment_group.comments.add(comment)
    except IntegrityError:
        print 'Failed to create a default comment group'
        return HttpResponseServerError()

    try:
        sample_case = Case(patient=sample_patient,
                           submitter=worker,
                           lock_holder=None,
                           status=1,
                           priority=10,
                           submitter_comments=comment_group,
                           date_opened="2012-12-12")
        sample_case.save()
    except IntegrityError:
        print 'Failed to create a default worker user'
        return HttpResponseServerError()

    return [
        worker_user, worker, doctor_user, doctor, sample_patient, comment,
        comment_group, sample_case, doctor2_user, doctor2
    ]
def populate_default_test_data():
    ''' Populates the database with default test data. '''

    try:
        worker_user = createUser('theworker', '*****@*****.**', 'password')
        worker_user.save()
        worker = Worker(user=worker_user)
        worker.registration_time = timezone.now()
        worker.save()

    except IntegrityError:
        print 'Failed to create a default worker user'
        return HttpResponseServerError()

    try:
        doctor_user = createUser('thedoctor', '*****@*****.**', 'thepassword')
        doctor_user.save()
        doctor = Doctor(user=doctor_user)
        doctor.user_id = doctor_user.id
        doctor.registration_time = timezone.now()
        doctor.save()
    except IntegrityError:
        print 'Failed to create a default doctor'
        return HttpResponseServerError()

    try:
        doctor2_user = createUser('doctor2', '*****@*****.**', 'd2password')
        doctor2_user.save()
        doctor2 = Doctor(user=doctor2_user)
        doctor2.user_id = doctor2_user.id
        doctor2.registration_time = timezone.now()
        doctor2.save()
    except IntegrityError:
        print 'Failed to create a default doctor'
        return HttpResponseServerError()

    try:
        sample_patient = Patient(
                first_name="Alexis",
                last_name="Advantageous",
                gps_coordinates="101010",
                address="Yonge street",
                date_of_birth="1999-06-10",
                phone="646646646464",
                health_id="324324234",
                gender="Male",
                email="*****@*****.**"
            )

        sample_patient.save()
    except IntegrityError:
        print 'Failed to create a default patient'
        return HttpResponseServerError()

    try:
        comment = Comment(author=worker_user,
                          text="Trololololol.",
                          time_posted=timezone.now())
        comment.save()
    except IntegrityError:
        print 'Failed to create a default comment'
        return HttpResponseServerError()

    try:
        comment_group = CommentGroup()
        comment_group.save()
        comment_group.comments.add(comment)
    except IntegrityError:
        print 'Failed to create a default comment group'
        return HttpResponseServerError()

    try:
        sample_case = Case(
                patient=sample_patient,
                submitter=worker,
                lock_holder=None,
                status=1,
                priority=10,
                submitter_comments=comment_group,
                date_opened="2012-12-12"
            )
        sample_case.save()
    except IntegrityError:
        print 'Failed to create a default worker user'
        return HttpResponseServerError()

    return [worker_user, worker, doctor_user, doctor, sample_patient, comment,
            comment_group, sample_case, doctor2_user, doctor2]