示例#1
0
class TestViews(FormatTest, TestCase):
    def setUp(self):
        self.my_type = '[Biopsy - Views]'
        stderr.write(self.__str__())
        self.db_mock = DatabaseMock()
        self.db_mock.create_user()
        self.db_mock.create_patient()
        self.db_mock.create_exam_type()
        self.db_mock.create_biopsy_status()
        self.db_mock.create_exam_biopsy()
        self.db_mock.create_biopsy(1)
        self.client = Client()
        self.client.login(username='******', password='******')


    def test_register_biopsy(self):
        response = self.client.post('/biopsia/', {
            'biopsy_id': '1',
            'examination_time': '12:00',
            'clinical_information': 'teste exame de biopsia',
            'macroscopic': 'Macroscopia',
            'microscopic': 'Microscopia',
            'conclusion': 'Conclusao',
            'note': 'Anotacao qualquer',
            'footer': 'Legenda qualquer'
        })

        biopsy_registered = Biopsy.objects.get(clinical_information="teste exame de biopsia")
        biopsy_registered.examination_time | should | equal_to(datetime.time(12, 0))
        biopsy_registered.clinical_information | should | equal_to('teste exame de biopsia')
        biopsy_registered.macroscopic | should | equal_to('Macroscopia')
        biopsy_registered.microscopic | should | equal_to('Microscopia')
        biopsy_registered.conclusion | should | equal_to('Conclusao')
        biopsy_registered.note | should | equal_to('Anotacao qualquer')
        biopsy_registered.footer | should | equal_to('Legenda qualquer')

        # If the method is executed sucessfully, the final instruction is to redirect
        # Status code 302 means sucessfully redirected
        response.status_code | should | equal_to(302)
示例#2
0
class TestViews(FormatTest, TestCase):

    def setUp(self):
        self.my_type = '[Exam - Views]'
        stderr.write(self.__str__())

        self.mock = DatabaseMock()
        self.mock.create_exam_type()
        self.mock.create_user()

        self.client = Client()
        self.client.login(username='******', password='******')

    def test_new_exam(self):
        self.mock.create_patient()
        response = self.client.post('/exame/novo/', {
            'patient_id': '1',
        })

        response.status_code | should | be(200)

    def test_register_exam(self):
        from exam.models import Exam
        before_save_exam = list(Exam.objects.all())

        self.mock.create_biopsy_status()
        response = self.client.post('/exame/registrar/', {
            'patient_id': '1',
            'receipt_date': '01/01/2000',
            'request_date': '01/01/2000',
            'speciment_collection_date': '01/01/2000',
            'requesting_physician': 'Requesting Physician',
            'received_speciment': 'Received Speciment',
            'csrfmiddlewaretoken': 'csrf_token',
            'responsible_physician': 'Responsible Pyshician',
            'exam_type': '1',
        })

        after_save_exam = list(Exam.objects.all())

        response.status_code | should | be(200)
        len(after_save_exam) | should | be_greater_than(len(before_save_exam))

    def test_register_new_biopsy(self):
        from biopsy.models import Biopsy
        before_create_biopsy = list(Biopsy.objects.all())

        self.mock.create_biopsy_status()
        response = self.client.post('/exame/registrar/', {
            'patient_id': '1',
            'receipt_date': '01/01/2000',
            'request_date': '01/01/2000',
            'speciment_collection_date': '01/01/2000',
            'requesting_physician': 'Requesting Physician',
            'received_speciment': 'Received Speciment',
            'csrfmiddlewaretoken': 'csrf_token',
            'responsible_physician': 'Responsible Pyshician',
            'exam_type': '1',
        })

        after_create_biopsy = list(Biopsy.objects.all())

        response.status_code | should | be(200)
        len(after_create_biopsy) | should | be_greater_than(
            len(before_create_biopsy))

    def test_register_new_necropsy(self):
        from necropsy.models import Necropsy
        before_create_necropsy = list(Necropsy.objects.all())

        self.mock.create_necropsy_status()
        response = self.client.post('/exame/registrar/', {
            'patient_id': '1',
            'receipt_date': '01/01/2000',
            'request_date': '01/01/2000',
            'speciment_collection_date': '01/01/2000',
            'requesting_physician': 'Requesting Physician',
            'received_speciment': 'Received Speciment',
            'csrfmiddlewaretoken': 'csrf_token',
            'responsible_physician': 'Responsible Pyshician',
            'exam_type': '2',
        })

        after_create_necropsy = list(Necropsy.objects.all())

        response.status_code | should | be(200)
        len(after_create_necropsy) | should | be_greater_than(
            len(before_create_necropsy))

    def test_register_new_immunohistochemical(self):
        from immunohistochemical.models import ImmunoHistochemical
        before_create_immunohistochemical = list(
            ImmunoHistochemical.objects.all())

        self.mock.create_immunohistochemical_status()
        response = self.client.post('/exame/registrar/', {
            'patient_id': '1',
            'receipt_date': '01/01/2000',
            'request_date': '01/01/2000',
            'speciment_collection_date': '01/01/2000',
            'requesting_physician': 'Requesting Physician',
            'received_speciment': 'Received Speciment',
            'csrfmiddlewaretoken': 'csrf_token',
            'responsible_physician': 'Responsible Pyshician',
            'exam_type': '3',
        })

        after_create_immunohistochemical = list(
            ImmunoHistochemical.objects.all())

        response.status_code | should | be(200)
        len(after_create_immunohistochemical) | should | be_greater_than(
            len(before_create_immunohistochemical))

    def test_register_new_cytology(self):
        from cytology.models import Cytology
        before_create_cytology = list(
            Cytology.objects.all())

        self.mock.create_cytology_status
        response = self.client.post('/exame/registrar/', {
            'patient_id': '1',
            'receipt_date': '01/01/2000',
            'request_date': '01/01/2000',
            'speciment_collection_date': '01/01/2000',
            'requesting_physician': 'Requesting Physician',
            'received_speciment': 'Received Speciment',
            'csrfmiddlewaretoken': 'csrf_token',
            'responsible_physician': 'Responsible Pyshician',
            'exam_type': '4',
        })

        after_create_cytology = list(
            Cytology.objects.all())

        response.status_code | should | be(200)
        len(after_create_cytology) | should | be_greater_than(
            len(before_create_cytology))