Beispiel #1
0
    def test_get_now_application_success(self, test_client, db_session, auth_headers):
        num_created = 3
        NOWApplicationIdentityFactory.create_batch(size=num_created)

        get_resp = test_client.get(f'/now-applications', headers=auth_headers['full_auth_header'])
        assert get_resp.status_code == 200, get_resp.response
        get_data = json.loads(get_resp.data.decode())
        assert len(get_data['records']) == num_created
Beispiel #2
0
    def test_generate_document_returns_token(self, test_client, db_session,
                                             auth_headers):
        """Should return the a token for successful generation"""
        now_application = NOWApplicationFactory()
        now_application_identity = NOWApplicationIdentityFactory(
            now_application=now_application)

        changed_mine_no = str(now_application_identity.mine.mine_no + '1')
        data = {
            'now_application_guid':
            now_application_identity.now_application_guid,
            'template_data': {
                'mine_no': changed_mine_no
            }
        }

        post_resp = test_client.post(
            f'/now-applications/application-document-types/RJL/generate',
            json=data,
            headers=auth_headers['full_auth_header'])

        assert post_resp.status_code == 200
        post_data = json.loads(post_resp.data.decode())
        token_data = cache.get(NOW_DOCUMENT_DOWNLOAD_TOKEN(post_data['token']))
        assert token_data is not None
        assert token_data['template_data']['mine_no'] != changed_mine_no
        assert post_data['token']
    def test_get_verify_permit_mine(self, test_client, db_session,
                                    auth_headers):
        mine = MineFactory(operating=True)
        #by default, authorization_end_date in the PermitAmendmentFactory is >30days
        permit = PermitFactory(permit_no="CX-1",
                               mine=mine,
                               permit_amendments=1)
        now_app = NOWApplicationIdentityFactory(mine=mine)
        permit.permit_amendments[0].now_identity = now_app

        now_sub = NOWSubmissionFactory()
        now_app.messageid = now_sub.messageid

        get_resp = test_client.get(
            f'/verify/permit/now?a_PermitNumber={permit.permit_no}',
            headers=auth_headers['full_auth_header'])
        get_data = json.loads(get_resp.data.decode())
        assert get_resp.status_code == 200
        assert get_data['a_Result'] == "Success"
        assert str(now_sub.trackingnumber) in get_data['a_NoWInfo']
def test_delete_flag_in_nested_item_success_nested(db_session):
    now_app = NOWApplicationIdentityFactory()
    assert len(now_app.now_application.camps.details) == 0
    new_camp_detail = CampDetail(length=10)
    now_app.now_application.camps.details.append(new_camp_detail)
    assert len(now_app.now_application.camps.details) == 1

    now_app_dict = marshal(now_app.now_application, NOW_APPLICATION_MODEL)
    now_app_dict['camps']['details'][0][
        'state_modified'] = STATE_MODIFIED_DELETE_ON_PUT

    now_app.now_application.deep_update_from_dict(now_app_dict)

    na = NOWApplication.query.filter_by(
        now_application_id=now_app.now_application_id).first()
    assert len(na.camps.details) == 0
Beispiel #5
0
    def test_get_verify_mine_now(self, test_client, db_session, auth_headers):
        mine = MineFactory(operating=True)
        permit = PermitFactory(permit_no="CX-1",
                               mine=mine,
                               permit_amendments=1)
        now_app = NOWApplicationIdentityFactory(mine=mine)
        permit.permit_amendments[0].now_identity = now_app

        now_sub = NOWSubmissionFactory()

        get_resp = test_client.get(
            f'/verify/mine/now?a_MineNumber={mine.mine_no}',
            headers=auth_headers['full_auth_header'])
        get_data = json.loads(get_resp.data.decode())
        assert get_resp.status_code == 200
        assert get_data['a_Result'] == "Success"
        assert str(now_app.now_number) in get_data['a_NoWInfo']
def test_update_new_now_application_activity_detail(db_session):
    now_app = NOWApplicationIdentityFactory()
    assert len(now_app.now_application.camps.details) == 0

    now_app_dict = marshal(now_app.now_application, NOW_APPLICATION_MODEL)
    new_camp_detail = CampDetail(length=10)
    new_camp_detail_dict = marshal(new_camp_detail,
                                   NOW_APPLICATION_ACTIVITY_DETAIL_BASE)

    del new_camp_detail_dict['activity_detail_id']

    now_app_dict['camps']['details'].append(new_camp_detail_dict)

    now_app.now_application.deep_update_from_dict(now_app_dict)

    na = NOWApplication.query.filter_by(
        now_application_id=now_app.now_application_id).first()
    assert len(na.camps.details) == 1
Beispiel #7
0
    def test_get_application_document_with_context(self, test_client,
                                                   db_session, auth_headers):
        """Should return the rejection letter document type with form_spec with context-values"""
        now_application = NOWApplicationFactory()
        now_application_identity = NOWApplicationIdentityFactory(
            now_application=now_application)

        get_resp = test_client.get(
            f'/now-applications/application-document-types/RJL?context_guid={now_application_identity.now_application_guid}',
            headers=auth_headers['full_auth_header'])
        assert get_resp.status_code == 200, get_resp.response
        get_data = json.loads(get_resp.data.decode())
        assert get_data['document_template']
        assert get_data['document_template'].get('form_spec'), get_data
        mine_no_item = [
            x for x in get_data['document_template']['form_spec']
            if x['id'] == "mine_no"
        ][0]
        assert mine_no_item
        assert mine_no_item['id'] == 'mine_no'
        assert mine_no_item['context-value'] == str(
            now_application_identity.mine.mine_no)