def test_suggest_investigator_order(self): investigator1 = InvestigatorFactory(name='Daniel Neubeck', complaint_count=5) investigator2 = InvestigatorFactory(name='Jack Neubeck', complaint_count=10) self.rebuild_index() suggest_entries = SuggestInvestigator.query('neu')['Investigator'] suggest_entries[0]['tag_value']['display_value'].should.be.equal(investigator1.name) suggest_entries[1]['tag_value']['display_value'].should.be.equal(investigator2.name)
def _test_investigator_agency_iad(self): expected_allegations = [ OfficerAllegationFactory(allegation=AllegationFactory( investigator=InvestigatorFactory(agency='IAD')))] OfficerAllegationFactory(allegation=AllegationFactory( investigator=InvestigatorFactory(agency='IPRA'))) query_string = 'allegation__investigator__agency=IAD' expected_ids = [allegation.id for allegation in expected_allegations] self.check_built_query(query_string, expected_ids)
def test_title_should_not_capitalized(self): investigator = InvestigatorFactory() allegation = AllegationFactory(investigator=investigator) OfficerAllegationFactory(allegation=allegation) self.visit('/investigator/slugify/{id}'.format(id=investigator.id)) self.browser.title.should.equal(investigator.name)
def setUp(self): self.investigator = InvestigatorFactory() allegation = AllegationFactory(investigator=self.investigator) self.officer_allegation = \ OfficerAllegationFactory( allegation=allegation, final_outcome_class='disciplined' )
def test_browse_investigator_page(self): investigator = InvestigatorFactory() allegation = AllegationFactory(investigator=investigator) OfficerAllegationFactory(allegation=allegation) self.visit('/investigator/slugify/{id}'.format(id=investigator.id)) self.until( lambda: len(self.find_all('.complaint-row')).should.equal(1))
def test_get_instances_from_names(self): InvestigatorFactory(name='James Gallah') names = { 'Jason Van Dyke': [], 'invalid': [] } responses_builder = InvestigatorResponses(names) responses = responses_builder.get_instances_from_names() len(responses).should.equal(1) responses[0].entity.id.should.equal(self.investigator.id)
def test_string_suggest_cases(self): investigator = InvestigatorFactory(name='Jason Van Dyke') suggest_cases = ['jaso', 'jason v', 'ja va', 'Ja dyke', 'van dyke'] self.rebuild_index() for suggest_case in suggest_cases: suggest_entry = SuggestInvestigator.query( suggest_case)['Investigator'][0] suggest_entry['tag_value']['display_value'].should.be.equal( investigator.name)
def test_apostrophe_suggest_cases(self): investigator = InvestigatorFactory(name='O\'brien') suggest_cases = ['o', 'bri', 'o\'bri', '\'brie'] self.rebuild_index() for suggest_case in suggest_cases: suggest_entry = SuggestInvestigator.query( suggest_case)['Investigator'][0] suggest_entry['tag_value']['display_value'].should.be.equal( investigator.name)
def test_officer_and_investigator_name_displayed_as_in_database(self): officer = OfficerFactory(officer_last='III') investigator = InvestigatorFactory(name='IIII') rebuild_index() search_text = 'ii' self.until(lambda: self.fill_in('.ui-autocomplete-input', search_text)) self.until(lambda: self.find('.ui-autocomplete-input').get_attribute( 'value').should.equal(search_text)) self.until(lambda: self.should_see_text(officer.officer_last)) self.until(lambda: self.should_see_text(investigator.name))
def test_suggest_investigator(self): investigator = InvestigatorFactory(name='Daniel Neubeck') self.rebuild_index() num_allegations = OfficerAllegation.objects.filter(allegation__investigator=investigator).count() expect_investigator_label = '{name} ({count})'.format(name=investigator.name, count=num_allegations) suggest_entry = SuggestInvestigator.query('neu')['Investigator'][0] suggest_entry['tag_value']['display_value'].should.be.equal(investigator.name) suggest_entry['suggest_value'].should.be.equal(expect_investigator_label) SuggestInvestigator.query('something wrong')['Investigator'].should.be.equal([])
def test_invalid_investigator_count(self): investigator = InvestigatorFactory(complaint_count=100, discipline_count=99) allegation = AllegationFactory(investigator=investigator) OfficerAllegationFactory(allegation=allegation, final_outcome=DISCIPLINE_CODES[0], final_finding='SU') OfficerAllegationFactory( allegation=AllegationFactory(investigator=investigator), final_outcome=NO_DISCIPLINE_CODES[0]) data = self.fetch_officer_allegations( allegation__investigator=investigator.id) data[0]['investigator']['complaint_count'].should.equal(2) data[0]['investigator']['discipline_count'].should.equal(1)
def test_allegation_with_full_information(self): view_document_text = 'View' officer_gender = 'X' officer_gender_display = 'X' complaint_witness_gender = 'F' complaint_witness_race = 'Black' complaint_witness_age = 40 complaint_witness_text = 'Female, Black, Age 40' address1 = 4748 address2 = 'N Kimball Ave' addresss = '{add1} {add2}'.format(add1=address1, add2=address2) category = AllegationCategoryFactory() officer = OfficerFactory(gender=officer_gender) current_rank = 'SERGEANT OF POLICE' investigator = InvestigatorFactory(current_rank=current_rank) allegation = AllegationFactory( investigator=investigator, add1=address1, add2=address2, city='Chicago, IL', location='15') DocumentFactory(documentcloud_id=123, allegation=allegation) OfficerAllegationFactory(cat=category, officer=officer, allegation=allegation) ComplainingWitnessFactory( crid=allegation.crid, gender=complaint_witness_gender, allegation=allegation, race=complaint_witness_race, age=complaint_witness_age) self.visit_complaint_page(allegation.crid, category.id) self.until(lambda: self.find('.crid-number')) self.until(lambda: self.find('.allegation-category').text.should.be.equal(category.category)) self.find('.allegation-name').text.should.be.equal(category.allegation_name) self.should_see_text(officer.display_name, '.against-section') self.should_see_text(officer_gender_display, '.against-section') self.should_see_text(complaint_witness_text, '.complaining-witness-list') self.should_see_text(investigator.name, '.investigator .name') self.should_see_text(investigator.current_rank, '.investigator .rank') self.should_see_text(allegation.beat.name, '.location-detail') self.should_see_text(view_document_text, '.document-card') location_detail = self.find('.location-detail').text location_detail.should.contain(addresss) location_detail.should.contain(allegation.city) location_detail.should.contain(allegation.location)
def setUp(self): self.investigator = InvestigatorFactory() self.allegation = AllegationFactory(point=None, investigator=self.investigator)
def setUp(self): self.investigator = InvestigatorFactory(name='Jason Van Dyke') rebuild_index()
def test_absolute_url(self): investigator = InvestigatorFactory(name='Daniel Neubeck') investigator.absolute_url.should.equal( '/investigator/daniel-neubeck/%s' % investigator.id)