Ejemplo n.º 1
0
 def test_user_sees_correct_columns_and_data_in_csv(self):
     user = accounts_factories.app_reviewer('ebclc').user
     ebclc = Organization.objects.get(slug='ebclc')
     sub = intake_factories.FormSubmissionWithOrgsFactory(
         organizations=[ebclc], answers=ebclc_answers)
     app = sub.applications.first()
     update_1 = intake_factories.StatusUpdateFactory(
         application=app,
         status_type=StatusType.objects.get(slug='eligible'),
         author=user
     )
     update_1.created = PACIFIC_TIME.localize(datetime(2017, 1, 1))
     update_1.save()
     update_2 = intake_factories.StatusUpdateFactory(
         application=app,
         status_type=StatusType.objects.get(slug='granted'),
         author=user
     )
     update_2.created = PACIFIC_TIME.localize(datetime(2017, 1, 2))
     update_2.save()
     self.client.login(
         username=user.username, password=settings.TEST_USER_PASSWORD)
     response = self.client.get(reverse(self.view_name))
     self.assertEqual(200, response.status_code)
     result = response.content.decode('utf-8')
     expected_result_line_1 = str(
         'id,Link,Application Date,Applied on,Wants help with record in,'
         'Preferred contact methods,First name,Middle name,'
         'Last name,Preferred pronouns,Phone number,Alternate phone number,'
         'Email,Address,Date of birth,Citizenship status,'
         'Is currently being charged,Is serving a sentence,'
         'Is on probation or parole,Finished half probation,'
         'Reduced probation,RAP in other counties,Where/when,'
         'Has suspended license,Owes court fines/fees,'
         'Has been denied housing or employment,'
         'Denied housing/employment by,Seeking job that requires LiveScan,'
         'Registered under PC 290,'
         'Monthly income,On public benefits,Owns home,Household size,'
         'Reasons for applying,How they found out about this,'
         'Additional information,'
         'Understands might not qualify and could take a few months,'
         '"Consents to record access, filing, and court representation",'
         'Was transferred out,Has been opened,Latest status,'
         'Latest status date,Latest status author,Status history link')
     expected_result_line_2 = str(
         'Alameda,Text Message,Gabriel,Tiffany,Jenkins,She/Her/Hers,'
         '(415) 212-4848,(415) 212-4848,[email protected],'
         '"6230 Shawn View\nNorth John, VA\n80973",4/19/1983,'
         'Other/I don\'t know,No,No,Yes,Not on probation,Not on probation,'
         'No,,No,No,,,,,"$3,001.00",No,Yes,3,,from work,I want help,'
         '"Yes, I understand","Yes, I give them permission to do that",'
         'False,False,Granted,01/02/2017,[email protected],')
     self.assertIn(expected_result_line_1, result)
     self.assertTrue(result.startswith(expected_result_line_1))
     self.assertIn(expected_result_line_2, result)
Ejemplo n.º 2
0
def create_searchable_applicant_with_bad_data(context, org_slug=None):
    global SEARCHABLE_APPLICANT_ID
    if org_slug:
        org = Organization.objects.get(slug=org_slug)
    answers = mock.fake.contra_costa_county_form_answers(**{
        'first_name': 'Waldo',
        'last_name': 'Waldini',
        'phone_number': '5555555555',
        'alternate_phone_number': '5555555555',
        'email': 'waldo@odlaw',
        'contact_preferences': ['prefers_email', 'prefers_sms'],
        'email': 'waldo@odlaw',
        'dob.day': '28',
        'dob.month': 'February',
        'dob.year': '1972',
    })
    kwargs = dict(
        answers=answers,
        date_received=PACIFIC_TIME.localize(
            mock.fake.date_time_between('-4w', '-2w'))
        )
    if org_slug:
        kwargs.update(organizations=[org])
    sub = factories.FormSubmissionWithOrgsFactory(**kwargs)
    SEARCHABLE_APPLICANT_ID = sub.id
Ejemplo n.º 3
0
 def test_expected_week(self):
     # 19th week of 2017
     same_week = [
         PACIFIC_TIME.localize(datetime.datetime(year=2017, month=5,
                                                 day=14)),  # sunday
         PACIFIC_TIME.localize(datetime.datetime(year=2017, month=5,
                                                 day=12)),  # friday
         PACIFIC_TIME.localize(datetime.datetime(year=2017, month=5,
                                                 day=11)),  # friday
         PACIFIC_TIME.localize(datetime.datetime(year=2017, month=5,
                                                 day=8)),  # monday
     ]
     # 20th week of 2017
     next_week = [
         PACIFIC_TIME.localize(datetime.datetime(year=2017, month=5,
                                                 day=15)),  # monday
         PACIFIC_TIME.localize(datetime.datetime(year=2017, month=5,
                                                 day=21)),  # sunday
     ]
     for date in same_week:
         result = statistics.as_year_week(date)
         self.assertEqual(result, '2017-19-1')
     for date in next_week:
         result = statistics.as_year_week(date)
         self.assertEqual(result, '2017-20-1')
Ejemplo n.º 4
0
def create_searchable_applicant(context, org_slug=None):
    global SEARCHABLE_APPLICANT_ID
    if org_slug:
        org = Organization.objects.get(slug=org_slug)
    answers = mock.fake.contra_costa_county_form_answers(
        first_name='Waldo',
        last_name='Waldini',
        phone_number='5555555555',
        email='*****@*****.**')
    kwargs = dict(answers=answers,
                  date_received=PACIFIC_TIME.localize(
                      mock.fake.date_time_between('-4w', '-2w')))
    if org_slug:
        kwargs.update(organizations=[org])
    sub = factories.FormSubmissionWithOrgsFactory(**kwargs)
    SEARCHABLE_APPLICANT_ID = sub.id
Ejemplo n.º 5
0
def get_newer_date():
    return PACIFIC_TIME.localize(fake.date_time_between('-3w', 'now'))
Ejemplo n.º 6
0
def get_old_date():
    return PACIFIC_TIME.localize(fake.date_time_between('-9w', '-6w'))
Ejemplo n.º 7
0
def get_start_date():
    return PACIFIC_TIME.localize(datetime.datetime(2016, 4, 18)).date()