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)
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)