class TestModels(FormatTest, TestCase): def setUp(self): self.my_type = '[Exam - Models]' stderr.write(self.__str__()) self.mock = DatabaseMock() def test_property_specific_exam(self): from exam.models import Exam from biopsy.models import Biopsy self.mock.create_exam_type() self.mock.create_exam_biopsy() exam = Exam.objects.earliest('id') exam.specific_exam | should | be_kind_of(Biopsy) def test_property_patient_information(self): from exam.models import Exam from patients.models import Paciente self.mock.create_patient() self.mock.create_exam_biopsy() exam = Exam.objects.get(id=1) exam.patient_information | should | be_kind_of(Paciente)
def setUp(self): self.my_type = "[Authentication - Views]" stderr.write(self.__str__()) self.mock = DatabaseMock() self.mock.create_user() self.client = Client()
def setUp(self): self.my_type = '[Patients - Views]' stderr.write(self.__str__()) self.db_mock = DatabaseMock() self.db_mock.create_patient() self.db_mock.create_user() self.client = Client() self.client.login(username='******', password='******')
def setUp(self): self.my_type = '[Necropsy - 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_necropsy_status() self.db_mock.create_exam_necropsy() self.db_mock.create_necropsy(1) self.client = Client() self.client.login(username='******', password='******')
class TestViews(FormatTest, TestCase): def setUp(self): self.my_type = "[Authentication - Views]" stderr.write(self.__str__()) self.mock = DatabaseMock() self.mock.create_user() self.client = Client() def test_log_out(self): self.client.post("/", {"username": "******", "password": "******"}) response = self.client.get("/sair/") response.status_code | should | equal_to(302) # User inactive needs to be implemented. # User LDAP authentication error needs to be implemented. def test_sign_in(self): # User not authenticated. template_in_response = False response = self.client.get("/") response.status_code | should | equal_to(200) for i in range(0, len(response.templates)): # Search for template 'sign_in.html' in response object. if response.templates[i].name == "sign_in.html": template_in_response = True break template_in_response | should | equal_to(True) # User authenticating. Sucessfully redirected. response = self.client.post("/", {"username": "******", "password": "******"}) response.status_code | should | equal_to(302) # User authenticating. Failed authentication, invalid login. self.client.get("/sair/") response = self.client.post("/", {"username": "******", "password": "******"}) response.status_code | should | equal_to(200) response.content | should | be_like(r".*Nome de usuário ou senha incorretos\..*", re.S)
class TestViews(FormatTest, TestCase): def setUp(self): self.my_type = '[Patients - Views]' stderr.write(self.__str__()) self.db_mock = DatabaseMock() self.db_mock.create_patient() self.db_mock.create_user() self.client = Client() self.client.login(username='******', password='******') def test_patient_profile(self): patient = Paciente.objects.using('hub').get(codigo = 1) response = self.client.get('/paciente/' + str(patient.codigo)) response.status_code | should | equal_to(200) #Verifying if the patient name is on HTML content. self.assertContains(response, patient.nome) def test_search_results(self): patient = Paciente.objects.using('hub').get(codigo = 1) response = self.client.get('/resultados/') response.status_code | should | equal_to(302) response = self.client.post('/resultados/', {'patient':patient.nome, 'report':patient.prontuario, 'date':'', 'mother_name':''}) response.status_code | should | equal_to(200) self.assertContains(response, patient.nome) def test_search_patient(self): #Search for 1 Patient. patients_result = search_patient('Test Patient', '', '', '') patients_result["empty_results"] | should | be(False) patients_result["empty_fields"] | should | be(False) patients_result["patients"].count() | should | be(1) patients_result["patients"][0].nome | should | equal_to('Test Patient') #Search for more than 1 Patient. patient = Paciente() patient.codigo = 2 patient.nome = 'Test Patient2' patient.cpf = '11111111111' patient.nome_mae = 'Patient Mother' patient.nome_pai = 'Patient Father' patient.dt_nascimento = timezone.now() patient.nac_codigo = 1 patient.cor = 'Test Color' patient.sexo = 'Male' patient.naturalidade = 'Test' patient.prontuario = 111111111 patient.dt_obito = timezone.now() patient.rg = '111' patient.observacao = '' patient.prnt_ativo = 'Active' patient.sexo_biologico = 'Male' patient.nro_cartao_saude = 1111111 patient.save(using='hub') patients_result = search_patient('Test','','','') patients_result["empty_results"] | should | be(False) patients_result["empty_fields"] | should | be(False) patients_result["patients"].count() | should | be(2) patients_result["patients"][0].nome | should | equal_to('Test Patient') patients_result["patients"][1].nome | should | equal_to('Test Patient2') #Search for 0 Patient. patients_result = search_patient('Nothing','','','') patients_result["empty_results"] | should | be(True) patients_result["empty_fields"] | should | be(False) patients_result["patients"].count() | should | be(0) #Search for empty fields patients_result = search_patient('','','','') patients_result["empty_fields"] | should | be(True)
def setUp(self): self.my_type = '[Exam - Models]' stderr.write(self.__str__()) self.mock = DatabaseMock()
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))
class TestViews(FormatTest, TestCase): def setUp(self): self.my_type = '[Necropsy - 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_necropsy_status() self.db_mock.create_exam_necropsy() self.db_mock.create_necropsy(1) self.client = Client() self.client.login(username='******', password='******') def test_register_necropsy(self): response = self.client.post('/autopsia/', { 'necropsy_id': '2', 'examination_time': '12:00', 'clinical_information': 'teste exame de necropsia', 'main_disease': 'Doenca Principal', 'consequential_final_disease': 'Consequencia da Doenca', 'contributors_disease': 'Doencas Contribuintes', 'consequential_disease': 'Consequencia da Doenca', 'other_diseases': 'Outras Doencas', 'note': 'Nota', 'footer': 'Legenda' }) necropsy_registered = Necropsy.objects.get(clinical_information='teste exame de necropsia') necropsy_registered.examination_time | should | equal_to(datetime.time(12, 0)) necropsy_registered.clinical_information | should | equal_to('teste exame de necropsia') necropsy_registered.main_disease | should | equal_to('Doenca Principal') necropsy_registered.consequential_final_disease | should | equal_to('Consequencia da Doenca') necropsy_registered.contributors_disease | should | equal_to('Doencas Contribuintes') necropsy_registered.consequential_disease | should | equal_to('Consequencia da Doenca') necropsy_registered.other_diseases | should | equal_to('Outras Doencas') necropsy_registered.note | should | equal_to('Nota') necropsy_registered.footer | should | equal_to('Legenda') # If the method is executed sucessfully, the final instruction is to render # Status code 200 means sucessfully redered response.status_code | should | equal_to(302)
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)