Beispiel #1
0
    def test_calc_age_returns_none_if__both_dates_missing(self):
        examination_overview = ExaminationOverview(
            ExaminationMocks.get_case_index_response_content()['examinations']
            [0])
        examination_overview.date_of_birth = None
        examination_overview.date_of_death = None
        result = examination_overview.calc_age()

        self.assertIsNone(result)
Beispiel #2
0
 def test_calc_age_returns_none_if_date_of_death_missing(self):
     examination_overview = ExaminationOverview(
         ExaminationMocks.get_case_index_response_content()['examinations']
         [0])
     birth_date = '2019-02-02T02:02:02.000Z'
     examination_overview.date_of_birth = parse_datetime(birth_date)
     examination_overview.date_of_death = None
     result = examination_overview.calc_age()
     self.assertIsNone(result)
Beispiel #3
0
 def test_calc_created_days_ago_returns_correct_number_of_days_if_case_created_date_present(
         self):
     examination_overview = ExaminationOverview(
         ExaminationMocks.get_case_index_response_content()['examinations']
         [0])
     case_created_date = datetime.today() - timedelta(days=1)
     examination_overview.case_created_date = case_created_date
     result = examination_overview.calc_created_days_ago()
     expected_days = 1
     self.assertEqual(result, expected_days)
Beispiel #4
0
 def test_calc_last_admission_days_ago_returns_0_if_date_of_admission_missing(
         self):
     examination_overview = ExaminationOverview(
         ExaminationMocks.get_case_index_response_content()['examinations']
         [0])
     admission_date = None
     examination_overview.last_admission = parse_datetime(admission_date)
     result = examination_overview.calc_last_admission_days_ago()
     expected_days = 0
     self.assertEqual(result, expected_days)
Beispiel #5
0
 def test_calc_age_correctly_calculates_the_age_if_dates_present(self):
     examination_overview = ExaminationOverview(
         ExaminationMocks.get_case_index_response_content()['examinations']
         [0])
     birth_date = '2018-02-02T02:02:02.000Z'
     death_date = '2019-02-02T02:02:02.000Z'
     examination_overview.date_of_birth = parse_datetime(birth_date)
     examination_overview.date_of_death = parse_datetime(death_date)
     result = examination_overview.calc_age()
     expected_age = 1
     self.assertEqual(result, expected_age)
Beispiel #6
0
    def test_landing_on_the_landing_page_returns_the_correct_template(self):
        self.set_auth_cookies()
        response = self.client.get('/')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertTemplateUsed(response, 'home/index.html')
        context_user = self.get_context_value(response.context, 'session_user')
        self.assertIsNot(context_user.examinations, None)
        self.assertIs(type(context_user.examinations), list)

        count = len(ExaminationMocks.get_case_index_response_content().get(
            'examinations'))
        self.assertEqual(len(context_user.examinations), count)
Beispiel #7
0
    def test_card_presenter_returns_a_correctly_formatted_appointment_date_if_date_present(
            self):
        examination_overview = ExaminationOverview(
            ExaminationMocks.get_case_index_response_content()['examinations']
            [0])
        given_date = '2019-02-02T02:02:02.000Z'
        examination_overview.appointment_date = parse_datetime(given_date)

        presenter = case_card_presenter(examination_overview)
        result = presenter['appointment_date']

        expected_date = '02.02.2019'
        self.assertEqual(result, expected_date)
Beispiel #8
0
    def test_sending_filters_to_the_landing_page_returns_the_correctly_set_filters(
            self):
        self.set_auth_cookies()
        response = self.client.get('/?page_number=1&location=1')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertTemplateUsed(response, 'home/index.html')
        context_user = self.get_context_value(response.context, 'session_user')
        self.assertIsNot(context_user.examinations, None)
        self.assertIs(type(context_user.examinations), list)

        count = len(ExaminationMocks.get_case_index_response_content().get(
            'examinations'))
        self.assertEqual(len(context_user.examinations), count)

        context_form = self.get_context_value(response.context, 'form')
        self.assertEqual(context_form.location, '1')
        self.assertEqual(context_form.person, None)