Beispiel #1
0
def test_post_mine_report_with_permit(test_client, db_session, auth_headers):
    mine = MineFactory(mine_reports=ONE_REPORT)
    mine_report = mine.mine_reports[0]

    mine_report_definition = MineReportDefinition.active()
    new_report_definition = [
        x for x in mine_report_definition if x.mine_report_definition_guid !=
        mine_report.mine_report_definition_guid
    ][0]

    data = {
        'mine_report_definition_guid':
        new_report_definition.mine_report_definition_guid,
        'submission_year': '2019',
        'due_date': '2019-07-05',
        'permit_guid': mine.mine_permit[0].permit_guid,
        'received_date': None,
    }
    post_resp = test_client.post(f'/mines/{mine.mine_guid}/reports',
                                 headers=auth_headers['full_auth_header'],
                                 json=data)
    post_data = json.loads(post_resp.data.decode())
    assert post_resp.status_code == 201
    assert post_data['permit_guid'] == str(mine.mine_permit[0].permit_guid)
Beispiel #2
0
def test_post_mine_report(test_client, db_session, auth_headers):
    mine = MineFactory(mine_reports=ONE_REPORT)
    mine_report = mine.mine_reports[0]

    mine_report_definition = MineReportDefinition.active()

    num_reports = len(mine.mine_reports)
    new_report_definition = [
        x for x in mine_report_definition if x.mine_report_definition_guid !=
        mine_report.mine_report_definition_guid
    ][0]
    data = {
        'mine_report_definition_guid':
        str(new_report_definition.mine_report_definition_guid),
        'submission_year':
        '2019',
        'due_date':
        '2019-07-05',
        'permit_guid':
        None,
        'received_date':
        None,
    }
    post_resp = test_client.post(f'/mines/{mine.mine_guid}/reports',
                                 headers=auth_headers['full_auth_header'],
                                 json=data)
    post_data = json.loads(post_resp.data.decode())

    updated_mine = Mine.find_by_mine_guid(str(mine.mine_guid))
    reports = updated_mine.mine_reports

    assert post_resp.status_code == 201
    assert len(reports) == num_reports + 1
    assert new_report_definition.mine_report_definition_id in [
        x.mine_report_definition_id for x in reports
    ]
Beispiel #3
0
 def get(self):
     return MineReportDefinition.active()
Beispiel #4
0
def RandomMineReportDefinitionWithDueDate():
    return random.choice([
        x.mine_report_definition_id for x in MineReportDefinition.active()
        if x.due_date_period_months and x.due_date_period_months > 0
    ])
Beispiel #5
0
def RandomMineReportDefinition():
    return random.choice(
        [x.mine_report_definition_id for x in MineReportDefinition.active()])