Esempio n. 1
0
def test_acs_can_create_notes(mockdata, client, session):
    with current_app.test_request_context():
        login_ac(client)
        officer = Officer.query.first()
        note = 'I can haz notez'
        ac = User.query.filter_by(email='*****@*****.**').first()
        form = TextForm(text_contents=note,
                        officer_id=officer.id,
                        creator_id=ac.id)

        rv = client.post(url_for('main.note_api', officer_id=officer.id),
                         data=form.data,
                         follow_redirects=True)

        assert rv.status_code == 200
        assert 'created' in rv.data

        created_note = Note.query.filter_by(text_contents=note).first()
        assert created_note is not None
        assert created_note.date_created is not None
Esempio n. 2
0
def test_admins_can_create_descriptions(mockdata, client, session):
    with current_app.test_request_context():
        login_admin(client)
        officer = Officer.query.first()
        text_contents = 'I can haz descriptionz'
        admin = User.query.filter_by(email='*****@*****.**').first()
        form = TextForm(text_contents=text_contents,
                        officer_id=officer.id,
                        creator_id=admin.id)

        rv = client.post(url_for('main.description_api',
                                 officer_id=officer.id),
                         data=form.data,
                         follow_redirects=True)

        assert rv.status_code == 200
        assert 'created' in rv.data

        created_description = Description.query.filter_by(
            text_contents=text_contents).first()
        assert created_description is not None
        assert created_description.date_created is not None
def test_acs_can_create_descriptions(mockdata, client, session):
    with current_app.test_request_context():
        login_ac(client)
        officer = Officer.query.first()
        description = 'A description'
        ac = User.query.filter_by(email='*****@*****.**').first()
        form = TextForm(text_contents=description,
                        officer_id=officer.id,
                        creator_id=ac.id)

        rv = client.post(url_for('main.description_api',
                                 officer_id=officer.id),
                         data=form.data,
                         follow_redirects=True)

        assert rv.status_code == 200
        assert 'created' in rv.data.decode('utf-8')

        created_description = Description.query.filter_by(
            text_contents=description).first()
        assert created_description is not None
        assert created_description.date_created is not None