def test_dataset_is_public_and_has_data(self): ''' We can accurately tell if a dataset is public and has data. ''' # create a department department = Department.create(name="B Police Department", short_name="BPD", load_defaults=True) # none of the datasets have data, so they should all return false assert department.dataset_is_public_and_has_data("complaints") == False assert department.dataset_is_public_and_has_data("uof") == False assert department.dataset_is_public_and_has_data("ois") == False assert department.dataset_is_public_and_has_data("assaults") == False # the total count should be zero assert department.displayable_dataset_count() == 0 # create incidents and verify that the datasets are now displayable CitizenComplaintBPD.create(department_id=department.id, opaque_id="12345abcde") assert department.dataset_is_public_and_has_data("complaints") == True assert department.displayable_dataset_count() == 1 UseOfForceIncidentBPD.create(department_id=department.id, opaque_id="23456bcdef") assert department.dataset_is_public_and_has_data("uof") == True assert department.displayable_dataset_count() == 2 OfficerInvolvedShootingBPD.create(department_id=department.id, opaque_id="34567cdefg") assert department.dataset_is_public_and_has_data("ois") == True assert department.displayable_dataset_count() == 3 # now make them all not public, and they should be false again department.is_public_citizen_complaints = False assert department.dataset_is_public_and_has_data("complaints") == False department.is_public_use_of_force_incidents = False assert department.dataset_is_public_and_has_data("uof") == False department.is_public_officer_involved_shootings = False assert department.dataset_is_public_and_has_data("ois") == False assert department.displayable_dataset_count() == 0
def test_dataset_is_public_and_has_data(self): ''' We can accurately tell if a dataset is public and has data. ''' # create a department department = Department.create(name="B Police Department", short_name="BPD", load_defaults=True) # none of the datasets have data, so they should all return false assert department.dataset_is_public_and_has_data("complaints") == False assert department.dataset_is_public_and_has_data("uof") == False assert department.dataset_is_public_and_has_data("ois") == False assert department.dataset_is_public_and_has_data("assaults") == False # create incidents and verify that the datasets are now displayable CitizenComplaintBPD.create(department_id=department.id, opaque_id="12345abcde") assert department.dataset_is_public_and_has_data("complaints") == True UseOfForceIncidentBPD.create(department_id=department.id, opaque_id="23456bcdef") assert department.dataset_is_public_and_has_data("uof") == True OfficerInvolvedShootingBPD.create(department_id=department.id, opaque_id="34567cdefg") assert department.dataset_is_public_and_has_data("ois") == True # now make them all not public, and they should be false again department.is_public_citizen_complaints = False assert department.dataset_is_public_and_has_data("complaints") == False department.is_public_use_of_force_incidents = False assert department.dataset_is_public_and_has_data("uof") == False department.is_public_officer_involved_shootings = False assert department.dataset_is_public_and_has_data("ois") == False
def test_data_status(self, testapp): department = Department.create(name="B Police Department", short_name="BPD", is_public=True) CitizenComplaintBPD.create(department_id=department.id, opaque_id="12345abcde") OfficerInvolvedShootingBPD.create(department_id=department.id, opaque_id="34567cdefg") department.is_public_officer_involved_shootings = False response = testapp.get("/", status=200) soup = BeautifulSoup(response.text) assert soup.find("a", href="/department/BPD/complaints") is not None assert soup.find("a", href="/department/BPD/useofforce") is None assert soup.find("a", href="/department/BPD/officerinvolvedshootings") is None
def test_updated_text_on_schema_pages(self, testapp): ''' The notice of the last time a dataset was updated is on all schema pages ''' department = Department.create(name="B Police Department", short_name="BPD", is_public=True) CitizenComplaintBPD.create(department_id=department.id, opaque_id="12345abcde") UseOfForceIncidentBPD.create(department_id=department.id, opaque_id="23456bcdef") OfficerInvolvedShootingBPD.create(department_id=department.id, opaque_id="34567cdefg") SRDepartment = Department.create(name="SR Police Department", short_name="SRPD", is_public=True) PursuitSRPD.create(department_id=SRDepartment.id, opaque_id="45678defgh") extractor_password = '******' bpd_extractor, envs = Extractor.from_department_and_password( department=department, password=extractor_password) bpd_extractor.last_contact = datetime.datetime(2012, 9, 16) srpd_extractor, envs = Extractor.from_department_and_password( department=SRDepartment, password=extractor_password) srpd_extractor.last_contact = datetime.datetime(2014, 11, 2) response = testapp.get("/department/BPD/schema/complaints/") soup = BeautifulSoup(response.text) updated_span = soup.find("span", {"class": "updated"}) assert updated_span is not None assert "Last Updated September 16, 2012" == updated_span.text response = testapp.get("/department/BPD/schema/useofforce/") soup = BeautifulSoup(response.text) updated_span = soup.find("span", {"class": "updated"}) assert updated_span is not None assert "Last Updated September 16, 2012" == updated_span.text response = testapp.get( "/department/BPD/schema/officerinvolvedshootings/") soup = BeautifulSoup(response.text) updated_span = soup.find("span", {"class": "updated"}) assert updated_span is not None assert "Last Updated September 16, 2012" == updated_span.text response = testapp.get("/department/SRPD/schema/pursuits/") soup = BeautifulSoup(response.text) updated_span = soup.find("span", {"class": "updated"}) assert updated_span is not None assert "Last Updated November 02, 2014" == updated_span.text
def test_data_status(self, testapp): department = Department.create(name="B Police Department", short_name="BPD", is_public=True) CitizenComplaintBPD.create(department_id=department.id, opaque_id="12345abcde") OfficerInvolvedShootingBPD.create(department_id=department.id, opaque_id="34567cdefg") department.is_public_officer_involved_shootings = False response = testapp.get("/", status=200) soup = BeautifulSoup(response.text) assert soup.find("a", href="/department/BPD/complaints") is not None assert soup.find("a", href="/department/BPD/useofforce") is None assert soup.find( "a", href="/department/BPD/officerinvolvedshootings") is None
def test_all_dept_links(self, testapp): department = Department.create(name="B Police Department", short_name="BPD", is_public=True) CitizenComplaintBPD.create(department_id=department.id, opaque_id="12345abcde") UseOfForceIncidentBPD.create(department_id=department.id, opaque_id="23456bcdef") OfficerInvolvedShootingBPD.create(department_id=department.id, opaque_id="34567cdefg") SRDepartment = Department.create(name="SR Police Department", short_name="SRPD", is_public=True) PursuitSRPD.create(department_id=SRDepartment.id, opaque_id="45678defgh") response = testapp.get("/", status=200) soup = BeautifulSoup(response.text) assert soup.find("a", href="/department/BPD/complaints") is not None assert soup.find("a", href="/department/BPD/useofforce") is not None assert soup.find( "a", href="/department/BPD/officerinvolvedshootings") is not None assert soup.find("a", href="/department/SRPD/pursuits") is not None