コード例 #1
0
def setup_info(test_client):
    permit = Permit.find_by_permit_guid(TEST_PERMIT_GUID_1)

    test_pa = PermitAmendment.create(permit, None, None, None, 'AMD')
    test_pa.save()

    test_pa_doc = PermitAmendmentDocument(
        document_name="test1.pdf",
        mine_guid=TEST_MINE_GUID,
        permit_amendment_id=test_pa.permit_amendment_id,
        document_manager_guid=TEST_DOCUMENT_MANAGER_GUID_1)
    test_pa_doc.save()

    test_orphan_doc = PermitAmendmentDocument(
        document_name="orphan.pdf",
        mine_guid=TEST_MINE_GUID,
        permit_amendment_id=None,
        document_manager_guid=TEST_DOCUMENT_MANAGER_GUID_2)
    test_orphan_doc.save()

    yield {
        'permit_amendment_1': test_pa,
        'permit_amendment_document_1': test_pa_doc,
        'test_orphan_document_1': test_orphan_doc
    }

    db.session.delete(test_pa)
    db.session.delete(test_pa_doc)
    db.session.delete(test_orphan_doc)
    try:
        #it may have been deleted by the test that executed, don't freak out.
        db.session.commit()
    except:
        pass
コード例 #2
0
ファイル: test_permit_resource.py プロジェクト: MaxWardle/mds
def test_post_permit_with_duplicate_permit_no(test_client, setup_info,
                                              auth_headers):
    permit = Permit.find_by_permit_guid(setup_info.get('mine_2_permit_guid'))
    data = {
        'mine_guid': setup_info.get('mine_1_guid'),
        'permit_no': permit.permit_no
    }
    post_resp = test_client.post('/permits',
                                 headers=auth_headers['full_auth_header'],
                                 json=data)

    assert post_resp.status_code == 400
コード例 #3
0
def test_put_permit(test_client, setup_info, auth_headers):
    permit_guid = setup_info.get('mine_2_permit_guid')
    permit = Permit.find_by_permit_guid(permit_guid)
    old_permit_status = permit.permit_status_code
    data = {'permit_status_code': 'C'}
    put_resp = test_client.put(
        '/permits/' + permit_guid, headers=auth_headers['full_auth_header'], json=data)

    put_data = json.loads(put_resp.data.decode())

    assert put_resp.status_code == 200
    assert put_data.get('permit_status_code') == 'C'
    assert put_data.get('permit_status_code') != old_permit_status
コード例 #4
0
def setup_info(test_client):
    permit = Permit.find_by_permit_guid(TEST_PERMIT_GUID_1)

    test_pa = PermitAmendment.create(permit, None, None, None, 'AMD')
    test_pa.save()

    yield {'permit_1': permit, 'permit_amendment_1': test_pa}

    db.session.delete(test_pa)
    try:
        #it may have been deleted by the test that executed, don't freak out.
        db.session.commit()
    except:
        pass
コード例 #5
0
ファイル: test_permit_model.py プロジェクト: num46664/mds
def test_permit_model_find_by_permit_guid(test_client, auth_headers):
    permit = Permit.find_by_permit_guid(TEST_PERMIT_GUID_1)
    assert str(permit.permit_guid) == TEST_PERMIT_GUID_1
コード例 #6
0
ファイル: test_permit_model.py プロジェクト: w8896699/mds
def test_permit_model_find_by_permit_guid(db_session):
    permit_guid = PermitFactory().permit_guid

    permit = Permit.find_by_permit_guid(str(permit_guid))
    assert permit.permit_guid == permit_guid