Ejemplo n.º 1
0
    def test_users_are_not_extractors(self):
        department = DepartmentFactory()
        department.save()
        user = User(username='******', email='*****@*****.**')
        user.departments.append(department)
        user.save()

        assert Extractor.get_by_id(user.id) == None
        assert Extractor.query.filter_by(username=user.username).first() == None
Ejemplo n.º 2
0
    def test_users_are_not_extractors(self):
        department = DepartmentFactory()
        department.save()
        user = User(username='******', email='*****@*****.**')
        user.departments.append(department)
        user.save()

        assert Extractor.get_by_id(user.id) == None
        assert Extractor.query.filter_by(
            username=user.username).first() == None
Ejemplo n.º 3
0
def make_admin_user():
    password = prompt_pass("Password")
    user = User.create(username="******", email="*****@*****.**", password=password, active=True)
    admin_role = Role(name='admin')
    admin_role.save()
    user.roles.append(admin_role)
    user.save()
Ejemplo n.º 4
0
def create_and_log_in_user(testapp=None,
                           department=None,
                           rolename=None,
                           username="******"):
    # set up a user
    user = User.create(username=username,
                       email="{}@example.com".format(username),
                       password="******")

    # associate a department if a department is passed
    if department:
        user.departments.append(department)

    user.active = True
    user.save()

    # associate a role if a name is passed
    if rolename:
        user_role = Role(name=rolename)
        user_role.save()
        user.roles.append(user_role)

    # login
    response = testapp.get("/login/")
    form = response.forms['loginForm']
    form['username'] = user.username
    form['password'] = '******'
    response = form.submit().follow()
    return user
Ejemplo n.º 5
0
def make_admin_user():
    password = prompt_pass("Password")
    user = User.create(username="******",
                       email="*****@*****.**",
                       password=password,
                       active=True)
    admin_role = Role(name='admin')
    admin_role.save()
    user.roles.append(admin_role)
    user.save()
Ejemplo n.º 6
0
def start_password_reset(user_id):
    user = User.get_by_id(user_id)
    if not user:
        abort(404)

    if request.method == 'POST':
        user.password_reset_uuid = str(uuid.uuid4())
        user.save()
        flash('User password reset engaged.', 'info')
        return redirect(url_for('admin.edit_user', user_id=user_id))

    return redirect(url_for('admin.edit_user', user_id=user_id))
Ejemplo n.º 7
0
def start_password_reset(user_id):
    user = User.get_by_id(user_id)
    if not user:
        abort(404)

    if request.method == 'POST':
        user.password_reset_uuid = str(uuid.uuid4())
        user.save()
        flash('User password reset engaged.', 'info')
        return redirect(url_for('admin.edit_user', user_id=user_id))

    return redirect(url_for('admin.edit_user', user_id=user_id))
Ejemplo n.º 8
0
def edit_user(user_id):
    user = User.get_by_id(user_id)
    if not user:
        abort(404)

    form = EditUserForm(request.form, departments=[d.id for d in user.departments])
    form.departments.choices = [(d.id, d.name) for d in Department.query.order_by('name')]

    if request.method == 'POST':
        user.departments = [Department.get_by_id(int(d)) for d in form.departments.data]
        user.save()
        flash('User updated.', 'info')
        return redirect(url_for('admin.admin_dashboard'))

    return render_template("admin/editUser.html", form=form, user=user)
Ejemplo n.º 9
0
def log_in_user(testapp, department):
    # set up a user
    user = User.create(username="******",
                       email="*****@*****.**",
                       password="******")
    user.departments.append(department)
    user.active = True
    user.save()
    # login
    response = testapp.get("/login/")
    form = response.forms['loginForm']
    form['username'] = user.username
    form['password'] = '******'
    response = form.submit().follow()
    return user
Ejemplo n.º 10
0
def test_client():
    delete_everything()
    department = Department.create(name="Busy Town Police Department", short_name="BTPD", load_defaults=True)
    user = User.create(username="******", email="*****@*****.**", password="******", active=True, is_admin=True)
    user.departments.append(department)
    user.save()

    test_client = JSONTestClient()
    # missing_data_mutator = MissingDataMutator()
    # fuzzed_data_mutator = FuzzedDataMutator()
    # known_bad_data_mutator = KnownBadDataMutator()
    # empty_data_mutator = EmptyDataMutator()
    # casing_mutator = CasingMutator()
    # condenisng_date_mutator = CondenisngDateMutator()
    # gap_date_mutator = GapDateMutator()

    test_client.run(department, [])
Ejemplo n.º 11
0
def edit_user(user_id):
    user = User.get_by_id(user_id)
    if not user:
        abort(404)

    form = EditUserForm(request.form,
                        departments=[d.id for d in user.departments])
    form.departments.choices = [(d.id, d.name)
                                for d in Department.query.order_by('name')]

    if request.method == 'POST':
        user.departments = [
            Department.get_by_id(int(d)) for d in form.departments.data
        ]
        user.save()
        flash('User updated.', 'info')
        return redirect(url_for('admin.admin_dashboard'))

    return render_template("admin/editUser.html", form=form, user=user)
Ejemplo n.º 12
0
def register():
    form = RegisterForm(request.form, csrf_enabled=False)
    if form.validate_on_submit():
        invite_code = Invite_Code.query.filter_by(code=form.invite_code.data).first()
        invite_code.used = True
        invite_code.save()

        new_user = User.create(
            username=form.username.data,
            email=form.email.data,
            password=form.password.data,
            active=True,
            department_id=invite_code.department_id,
        )

        flash("Thank you for registering. You can now log in.", "success")
        return redirect(url_for("public.home"))
    else:
        flash_errors(form)
    return render_template("public/register.html", form=form)
Ejemplo n.º 13
0
def register():
    form = RegisterForm(request.form, csrf_enabled=False)
    if form.validate_on_submit():
        invite_code = Invite_Code.query.filter_by(
            code=form.invite_code.data).first()
        invite_code.used = True
        invite_code.save()

        new_user = User.create(username=form.username.data,
                               email=form.email.data,
                               password=form.password.data,
                               active=True)

        new_user.departments.append(
            Department.get_by_id(invite_code.department_id))

        flash("Thank you for registering. You can now log in.", 'success')
        return redirect(url_for('public.home'))
    else:
        flash_errors(form)
    return render_template('public/register.html', form=form)
Ejemplo n.º 14
0
def create_and_log_in_user(testapp=None, department=None, rolename=None, username="******"):
    # set up a user
    user = User.create(username=username, email="{}@example.com".format(username), password="******")

    # associate a department if a department is passed
    if department:
        user.departments.append(department)

    user.active = True
    user.save()

    # associate a role if a name is passed
    if rolename:
        user_role = Role(name=rolename)
        user_role.save()
        user.roles.append(user_role)

    # login
    response = testapp.get("/login/")
    form = response.forms['loginForm']
    form['username'] = user.username
    form['password'] = '******'
    response = form.submit().follow()
    return user
Ejemplo n.º 15
0
 def test_password_is_nullable(self):
     user = User(username='******', email='*****@*****.**')
     user.save()
     assert user.password is None
Ejemplo n.º 16
0
def load_user(id):
    return User.get_by_id(int(id))
Ejemplo n.º 17
0
def load_user(id):
    return User.get_by_id(int(id))
Ejemplo n.º 18
0
 def test_created_at_defaults_to_datetime(self):
     user = User(username='******', email='*****@*****.**')
     user.save()
     assert bool(user.created_at)
     assert isinstance(user.created_at, dt.datetime)
Ejemplo n.º 19
0
    def test_get_by_id(self):
        user = User('foo', '*****@*****.**')
        user.save()

        retrieved = User.get_by_id(user.id)
        assert retrieved == user
Ejemplo n.º 20
0
def load_test_data():
    department = Department.query.filter_by(
        name="Indianapolis Metropolitan Police Department",
        short_name="IMPD").first()
    if not department:
        department = Department.create(
            name="Indianapolis Metropolitan Police Department",
            short_name="IMPD")
    if not User.query.filter_by(username="******").first():
        User.create(username="******",
                    email="*****@*****.**",
                    password="******",
                    active=True,
                    department_id=department.id)

    for filename in glob.glob('data/testdata/complaints/complaints.csv'):
        with open(filename, 'rt') as f:
            reader = csv.DictReader(f)
            for complaint in reader:
                officer_identifier = hashlib.md5(
                    (complaint.get("OFFNUM", None) +
                     Config.SECRET_KEY).encode('UTF-8')).hexdigest()
                opaque_id = hashlib.md5(
                    (complaint.get("INCNUM", None) +
                     Config.SECRET_KEY).encode('UTF-8')).hexdigest()

                CitizenComplaint.create(
                    opaque_id=opaque_id,
                    department_id=department.id,
                    occured_date=parse_csv_date(
                        complaint.get("OCCURRED_DT", None)),
                    division=complaint.get("UDTEXT24A", None),
                    precinct=complaint.get("UDTEXT24B", None),
                    shift=complaint.get("UDTEXT24C", None),
                    beat=complaint.get("UDTEXT24D", None),
                    disposition=complaint.get("FINDING", None),
                    allegation_type=complaint.get("ALG_CLASS", None),
                    allegation=complaint.get("ALLEGATION", None),
                    census_tract=None,
                    resident_race=complaint.get("RACE", None),
                    officer_race=complaint.get("OFF_RACE", None),
                    resident_sex=complaint.get("SEX", None),
                    officer_sex=complaint.get("OFF_SEX", None),
                    officer_identifier=officer_identifier,
                    officer_years_of_service=complaint.get(
                        "OFF_YR_EMPLOY", None),
                    officer_age=complaint.get("OFF_AGE", None),
                    resident_age=complaint.get("CIT_AGE", None))

    for filename in glob.glob('data/testdata/uof/uof.csv'):
        with open(filename, 'rt') as f:
            reader = csv.DictReader(f)
            for incident in reader:
                officer_identifier = hashlib.md5(
                    (incident.get("OFFNUM", None) +
                     Config.SECRET_KEY).encode('UTF-8')).hexdigest()
                opaque_id = hashlib.md5(
                    (incident.get("INCNUM", None) +
                     Config.SECRET_KEY).encode('UTF-8')).hexdigest()

                UseOfForceIncident.create(
                    department_id=department.id,
                    opaque_id=opaque_id,
                    occured_date=parse_csv_date(
                        incident.get("OCCURRED_DT", None)),
                    division=incident.get("UDTEXT24A", None),
                    precinct=incident.get("UDTEXT24B", None),
                    shift=incident.get("UDTEXT24C", None),
                    beat=incident.get("UDTEXT24D", None),
                    disposition=incident.get("DISPOSITION", None),
                    census_tract=None,
                    officer_force_type=incident.get("UOF_FORCE_TYPE", None),
                    resident_resist_type=None,
                    officer_weapon_used=None,
                    resident_weapon_used=None,
                    service_type=incident.get("SERVICE_TYPE", None),
                    arrest_made=incident.get("CIT_ARRESTED", None),
                    arrest_charges=incident.get("CITCHARGE_TYPE", None),
                    resident_injured=incident.get("CIT_INJURED", None),
                    resident_hospitalized=incident.get("CIT_HOSPITAL", None),
                    officer_injured=incident.get("OFF_INJURED", None),
                    officer_hospitalized=incident.get("OFF_HOSPITAL", None),
                    use_of_force_reason=incident.get("UOF_REASON", None),
                    resident_race=incident.get("RACE", None),
                    officer_race=incident.get("OFF_RACE", None),
                    resident_sex=incident.get("SEX", None),
                    officer_sex=incident.get("OFF_SEX", None),
                    officer_identifier=officer_identifier,
                    officer_years_of_service=incident.get(
                        "OFF_YR_EMPLOY", None),
                    officer_age=incident.get("OFF_AGE", None),
                    resident_age=incident.get("CIT_AGE", None),
                    officer_condition=incident.get("OFF_COND_TYPE", None),
                    resident_condition=incident.get("CIT_COND_TYPE", None))

    for filename in glob.glob('data/testdata/ois/ois.csv'):
        with open(filename, 'rt') as f:
            reader = csv.DictReader(f)
            for incident in reader:
                officer_identifier = hashlib.md5(
                    (incident.get("OFFNUM", None) +
                     Config.SECRET_KEY).encode('UTF-8')).hexdigest()
                opaque_id = hashlib.md5(
                    (incident.get("INCNUM", None) +
                     Config.SECRET_KEY).encode('UTF-8')).hexdigest()

                OfficerInvolvedShooting.create(
                    department_id=department.id,
                    opaque_id=opaque_id,
                    occured_date=parse_csv_date(
                        incident.get("OCCURRED_DT", None)),
                    division=incident.get("UDTEXT24A", None),
                    precinct=incident.get("UDTEXT24B", None),
                    shift=incident.get("UDTEXT24C", None),
                    beat=incident.get("UDTEXT24D", None),
                    disposition=incident.get("DISPOSITION", None),
                    census_tract=None,
                    officer_weapon_used=incident.get("WEAPON_TYPE", None),
                    resident_weapon_used=incident.get("CIT_WEAPON_TYPE", None),
                    service_type=incident.get("SERVICE_TYPE", None),
                    resident_race=incident.get("RACE", None),
                    officer_race=incident.get("OFF_RACE", None),
                    resident_sex=incident.get("SEX", None),
                    officer_sex=incident.get("OFF_SEX", None),
                    officer_identifier=officer_identifier,
                    officer_years_of_service=incident.get(
                        "OFF_YR_EMPLOY", None),
                    officer_age=incident.get("OFF_AGE", None),
                    resident_age=incident.get("CIT_AGE", None),
                    officer_condition=incident.get("OFF_COND_TYPE", None),
                    resident_condition=incident.get("CIT_COND_TYPE", None))

    for filename in glob.glob('data/testdata/denominators/denominators.csv'):
        with open(filename, 'rt') as f:
            reader = csv.DictReader(f)
            for month in reader:
                DenominatorValue.create(department_id=department.id,
                                        month=month.get("month", None),
                                        year=month.get("year", None),
                                        officers_out_on_service=month.get(
                                            "officers out on service", None))

    for filename in glob.glob('data/testdata/demographics/demographics.csv'):
        with open(filename, 'rt') as f:
            reader = csv.DictReader(f)
            for value in reader:
                DemographicValue.create(department_id=department.id,
                                        race=value.get("race", None),
                                        count=value.get("count", None),
                                        department_value=value.get(
                                            "cityOrDepartment",
                                            None) == "department")
Ejemplo n.º 21
0
def test_client():
    ''' Erase the database and load in a full suite of test data
    '''
    if not prompt_bool(
            "Are you sure you want to destroy and recreate Comport's database?"
    ):
        return

    delete_everything()

    # create a fake PD and admin user
    department = Department.create(
        name="Izquierda Metropolitan Police Department",
        short_name="IMPD",
        load_defaults=True)
    user = User.create(username="******",
                       email="*****@*****.**",
                       password="******",
                       active=True,
                       is_admin=True)
    user.departments.append(department)
    user.save()

    # create some fake officer out on service data
    date_now = datetime.datetime.now()
    date_step = date_now - relativedelta(months=30)
    while date_step.year < date_now.year or date_step.month < date_now.month:
        DenominatorValue.create(
            department_id=department.id,
            month=date_step.month,
            year=date_step.year,
            officers_out_on_service=(100000 + (randint(0, 46000) - 23000)))
        date_step = date_step + relativedelta(months=1)

    # create some fake demographic data
    demo_template = [
        dict(race="Asian", city_factor=0.0194, dept_factor=0.0013),
        dict(race="Black", city_factor=0.2452, dept_factor=0.1402),
        dict(race="Hispanic", city_factor=0.0861, dept_factor=0.0253),
        dict(race="Other", city_factor=0.0699, dept_factor=0.0101),
        dict(race="White", city_factor=0.5794, dept_factor=0.8231)
    ]

    # for the city
    city_population = 100000 + round(100000 * ((randint(0, 16) / 100) - .08))
    for value in demo_template:
        DemographicValue.create(department_id=department.id,
                                race=value["race"],
                                count=round(city_population *
                                            value["city_factor"]),
                                department_value=False)

    # for the department
    dept_population = 1500 + round(1500 * ((randint(0, 16) / 100) - .08))
    for value in demo_template:
        DemographicValue.create(department_id=department.id,
                                race=value["race"],
                                count=round(dept_population *
                                            value["dept_factor"]),
                                department_value=True)

    # create a JSON test client and run it
    test_client = JSONTestClient()
    mutations = []
    # mutations.append(MissingDataMutator())
    # mutations.append(FuzzedDataMutator())
    # mutations.append(KnownBadDataMutator())
    # mutations.append(EmptyDataMutator())
    # mutations.append(CasingMutator())
    # mutations.append(CondenisngDateMutator())
    # mutations.append(GapDateMutator())

    test_client.run(department, mutations)
Ejemplo n.º 22
0
def test_client():
    ''' Erase the database and load in a full suite of test data
    '''
    if not prompt_bool("Are you sure you want to destroy and recreate Comport's database?"):
        return

    delete_everything()

    # create a fake PD and admin user
    department = Department.create(name="Izquierda Metropolitan Police Department", short_name="IMPD", load_defaults=True)
    user = User.create(username="******", email="*****@*****.**", password="******", active=True, is_admin=True)
    user.departments.append(department)
    user.save()

    # create some fake officer out on service data
    date_now = datetime.datetime.now()
    date_step = date_now - relativedelta(months=30)
    while date_step.year < date_now.year or date_step.month < date_now.month:
        DenominatorValue.create(
            department_id=department.id,
            month=date_step.month,
            year=date_step.year,
            officers_out_on_service=(100000 + (randint(0, 46000) - 23000))
        )
        date_step = date_step + relativedelta(months=1)

    # create some fake demographic data
    demo_template = [
        dict(race="Asian", city_factor=0.0194, dept_factor=0.0013),
        dict(race="Black", city_factor=0.2452, dept_factor=0.1402),
        dict(race="Hispanic", city_factor=0.0861, dept_factor=0.0253),
        dict(race="Other", city_factor=0.0699, dept_factor=0.0101),
        dict(race="White", city_factor=0.5794, dept_factor=0.8231)
    ]

    # for the city
    city_population = 100000 + round(100000 * ((randint(0, 16) / 100) - .08))
    for value in demo_template:
        DemographicValue.create(
            department_id=department.id,
            race=value["race"],
            count=round(city_population * value["city_factor"]),
            department_value=False
        )

    # for the department
    dept_population = 1500 + round(1500 * ((randint(0, 16) / 100) - .08))
    for value in demo_template:
        DemographicValue.create(
            department_id=department.id,
            race=value["race"],
            count=round(dept_population * value["dept_factor"]),
            department_value=True
        )

    # create a JSON test client and run it
    test_client = JSONTestClient()
    mutations = []
    # mutations.append(MissingDataMutator())
    # mutations.append(FuzzedDataMutator())
    # mutations.append(KnownBadDataMutator())
    # mutations.append(EmptyDataMutator())
    # mutations.append(CasingMutator())
    # mutations.append(CondenisngDateMutator())
    # mutations.append(GapDateMutator())

    test_client.run(department, mutations)
Ejemplo n.º 23
0
 def test_check_password(self):
     user = User.create(username="******", email="*****@*****.**", password="******")
     assert user.check_password('foobarbaz123') is True
     assert user.check_password("barfoobaz") is False
Ejemplo n.º 24
0
 def test_created_at_defaults_to_datetime(self):
     user = User(username='******', email='*****@*****.**')
     user.save()
     assert bool(user.created_at)
     assert isinstance(user.created_at, dt.datetime)
Ejemplo n.º 25
0
    def test_get_by_id(self):
        user = User('foo', '*****@*****.**')
        user.save()

        retrieved = User.get_by_id(user.id)
        assert retrieved == user
Ejemplo n.º 26
0
 def test_password_is_nullable(self):
     user = User(username='******', email='*****@*****.**')
     user.save()
     assert user.password is None
Ejemplo n.º 27
0
 def test_check_password(self):
     user = User.create(username="******",
                        email="*****@*****.**",
                        password="******")
     assert user.check_password('foobarbaz123') is True
     assert user.check_password("barfoobaz") is False
Ejemplo n.º 28
0
def load_test_data():
    department = Department.query.filter_by(name="Indianapolis Metropolitan Police Department", short_name="IMPD").first()
    if not department:
        department = Department.create(name="Indianapolis Metropolitan Police Department", short_name="IMPD")
    if not User.query.filter_by(username="******").first():
        User.create(username="******", email="*****@*****.**", password="******", active=True, department_id=department.id)

    for filename in glob.glob('data/testdata/complaints/complaints.csv'):
        with open(filename, 'rt') as f:
            reader = csv.DictReader(f)
            for complaint in reader:
                officer_identifier = hashlib.md5((complaint.get("OFFNUM", None) + Config.SECRET_KEY).encode('UTF-8')).hexdigest()
                opaque_id = hashlib.md5((complaint.get("INCNUM", None) + Config.SECRET_KEY).encode('UTF-8')).hexdigest()

                CitizenComplaint.create(
                    opaque_id=opaque_id,
                    department_id=department.id,
                    occured_date=parse_csv_date(complaint.get("OCCURRED_DT", None)),
                    division=complaint.get("UDTEXT24A", None),
                    precinct=complaint.get("UDTEXT24B", None),
                    shift=complaint.get("UDTEXT24C", None),
                    beat=complaint.get("UDTEXT24D", None),
                    disposition=complaint.get("FINDING", None),
                    allegation_type=complaint.get("ALG_CLASS", None),
                    allegation=complaint.get("ALLEGATION", None),
                    census_tract=None,
                    resident_race=complaint.get("RACE", None),
                    officer_race=complaint.get("OFF_RACE", None),
                    resident_sex=complaint.get("SEX", None),
                    officer_sex=complaint.get("OFF_SEX", None),
                    officer_identifier=officer_identifier,
                    officer_years_of_service=complaint.get("OFF_YR_EMPLOY", None),
                    officer_age=complaint.get("OFF_AGE", None),
                    resident_age=complaint.get("CIT_AGE", None)
                )

    for filename in glob.glob('data/testdata/uof/uof.csv'):
        with open(filename, 'rt') as f:
            reader = csv.DictReader(f)
            for incident in reader:
                officer_identifier = hashlib.md5((incident.get("OFFNUM", None) + Config.SECRET_KEY).encode('UTF-8')).hexdigest()
                opaque_id = hashlib.md5((incident.get("INCNUM", None) + Config.SECRET_KEY).encode('UTF-8')).hexdigest()

                UseOfForceIncident.create(
                    department_id=department.id,
                    opaque_id=opaque_id,
                    occured_date=parse_csv_date(incident.get("OCCURRED_DT", None)),
                    division=incident.get("UDTEXT24A", None),
                    precinct=incident.get("UDTEXT24B", None),
                    shift=incident.get("UDTEXT24C", None),
                    beat=incident.get("UDTEXT24D", None),
                    disposition=incident.get("DISPOSITION", None),
                    census_tract=None,
                    officer_force_type=incident.get("UOF_FORCE_TYPE", None),
                    resident_resist_type=None,
                    officer_weapon_used=None,
                    resident_weapon_used=None,
                    service_type=incident.get("SERVICE_TYPE", None),
                    arrest_made=incident.get("CIT_ARRESTED", None),
                    arrest_charges=incident.get("CITCHARGE_TYPE", None),
                    resident_injured=incident.get("CIT_INJURED", None),
                    resident_hospitalized=incident.get("CIT_HOSPITAL", None),
                    officer_injured=incident.get("OFF_INJURED", None),
                    officer_hospitalized=incident.get("OFF_HOSPITAL", None),
                    use_of_force_reason=incident.get("UOF_REASON", None),
                    resident_race=incident.get("RACE", None),
                    officer_race=incident.get("OFF_RACE", None),
                    resident_sex=incident.get("SEX", None),
                    officer_sex=incident.get("OFF_SEX", None),
                    officer_identifier=officer_identifier,
                    officer_years_of_service=incident.get("OFF_YR_EMPLOY", None),
                    officer_age=incident.get("OFF_AGE", None),
                    resident_age=incident.get("CIT_AGE", None),
                    officer_condition=incident.get("OFF_COND_TYPE", None),
                    resident_condition=incident.get("CIT_COND_TYPE", None)
                )

    for filename in glob.glob('data/testdata/ois/ois.csv'):
        with open(filename, 'rt') as f:
            reader = csv.DictReader(f)
            for incident in reader:
                officer_identifier = hashlib.md5((incident.get("OFFNUM", None) + Config.SECRET_KEY).encode('UTF-8')).hexdigest()
                opaque_id = hashlib.md5((incident.get("INCNUM", None) + Config.SECRET_KEY).encode('UTF-8')).hexdigest()

                OfficerInvolvedShooting.create(
                    department_id=department.id,
                    opaque_id=opaque_id,
                    occured_date=parse_csv_date(incident.get("OCCURRED_DT", None)),
                    division=incident.get("UDTEXT24A", None),
                    precinct=incident.get("UDTEXT24B", None),
                    shift=incident.get("UDTEXT24C", None),
                    beat=incident.get("UDTEXT24D", None),
                    disposition=incident.get("DISPOSITION", None),
                    census_tract=None,
                    officer_weapon_used=incident.get("WEAPON_TYPE", None),
                    resident_weapon_used=incident.get("CIT_WEAPON_TYPE", None),
                    service_type=incident.get("SERVICE_TYPE", None),
                    resident_race=incident.get("RACE", None),
                    officer_race=incident.get("OFF_RACE", None),
                    resident_sex=incident.get("SEX", None),
                    officer_sex=incident.get("OFF_SEX", None),
                    officer_identifier=officer_identifier,
                    officer_years_of_service=incident.get("OFF_YR_EMPLOY", None),
                    officer_age=incident.get("OFF_AGE", None),
                    resident_age=incident.get("CIT_AGE", None),
                    officer_condition=incident.get("OFF_COND_TYPE", None),
                    resident_condition=incident.get("CIT_COND_TYPE", None)
                )

    for filename in glob.glob('data/testdata/denominators/denominators.csv'):
        with open(filename, 'rt') as f:
            reader = csv.DictReader(f)
            for month in reader:
                DenominatorValue.create(
                    department_id=department.id,
                    month=month.get("month", None),
                    year=month.get("year", None),
                    officers_out_on_service=month.get("officers out on service", None)
                )

    for filename in glob.glob('data/testdata/demographics/demographics.csv'):
        with open(filename, 'rt') as f:
            reader = csv.DictReader(f)
            for value in reader:
                DemographicValue.create(
                    department_id=department.id,
                    race=value.get("race", None),
                    count=value.get("count", None),
                    department_value=value.get("cityOrDepartment", None) == "department"
                )