コード例 #1
0
def test_no_api_key():
    with requests_mock.Mocker() as mock:
        mock.get(URL + "&docketID=" + DOCKET_ID,
                 json='The test yields a bad api key',
                 status_code=403)

        with pytest.raises(reggov_api_doc_error.IncorrectApiKeyException):
            get_docket('', DOCKET_ID)
コード例 #2
0
def test_maxed_api_key():
    with requests_mock.Mocker() as mock:
        mock.get(URL + API_KEY + "&docketID=" + DOCKET_ID,
                 json='The test yields a overused api key',
                 status_code=429)

        with pytest.raises(reggov_api_doc_error.ExceedCallLimitException):
            get_docket(API_KEY, DOCKET_ID)
コード例 #3
0
def test_no_docket_id():
    with requests_mock.Mocker() as mock:
        mock.get(URL + API_KEY + "&docketID=",
                 json='The test yields a bad id',
                 status_code=404)

        with pytest.raises(reggov_api_doc_error.BadDocIDException):
            get_docket(API_KEY, '')
コード例 #4
0
def test_bad_docket_id_pattern():
    with requests_mock.Mocker() as mock:
        bad_docket = 'b4d' + DOCKET_ID + 'b4d'
        mock.get(URL + API_KEY + "&docketID=" + bad_docket,
                 json='The test yields a bad id pattern',
                 status_code=400)

        with pytest.raises(reggov_api_doc_error.IncorrectIDPatternException):
            get_docket(API_KEY, bad_docket)
コード例 #5
0
def test_bad_docket_id():
    with requests_mock.Mocker() as mock:
        bad_docket = DOCKET_ID + '-0101'
        mock.get(URL + API_KEY + "&docketID=" + bad_docket,
                 json='The test yields a bad id',
                 status_code=404)

        with pytest.raises(reggov_api_doc_error.BadDocIDException):
            get_docket(API_KEY, bad_docket)
コード例 #6
0
def test_get_docket():
    with requests_mock.Mocker() as mock:
        mock.get(URL + API_KEY + "&docketID=" + DOCKET_ID,
                 json={'test': 'The test is successful'})
        response = get_docket(API_KEY, DOCKET_ID)

        assert (response == {'test': 'The test is successful'})
コード例 #7
0
def find_docket_data(manager, job, job_id):
    print("Getting docket from regulations.gov...\n")
    data = get_docket(manager.api_key, job['docket_id'])
    LOGGER.info("Job#%s: Packaging docket..", str(job_id))
    results = package_docket(data, manager.client_id, job_id)
    return results