Exemplo n.º 1
0
def test_next_page_token(patch_base_class, test_full_refresh_config):
    setup_responses()
    stream = LeverHiringStream(**test_full_refresh_config)
    inputs = {
        "response":
        requests.get("https://api.sandbox.lever.co/v0/example_endpoint")
    }
    expected_token = {
        "offset":
        "%5B1628543173558%2C%227bf8c1ac-4a68-450f-bea0-a1e2c3f5aeaf%22%5D"
    }
    assert stream.next_page_token(**inputs) == expected_token
Exemplo n.º 2
0
def test_request_headers(patch_base_class, test_full_refresh_config):
    stream = LeverHiringStream(**test_full_refresh_config)
    inputs = {
        "stream_slice": {
            "slice": "test_slice"
        },
        "stream_state": {
            "updatedAt": 1600000000000
        },
        "next_page_token": {
            "offset": "next_page_cursor"
        },
    }
    assert stream.request_headers(**inputs) == {}
Exemplo n.º 3
0
def test_request_params(patch_base_class, test_full_refresh_config):
    stream = LeverHiringStream(**test_full_refresh_config)
    inputs = {
        "stream_slice": {
            "slice": "test_slice"
        },
        "stream_state": {
            "updatedAt": 1600000000000
        },
        "next_page_token": {
            "offset": "next_page_cursor"
        },
    }
    expected_params = {"limit": stream.page_size, "offset": "next_page_cursor"}
    assert stream.request_params(**inputs) == expected_params
Exemplo n.º 4
0
def test_parse_response(patch_base_class, test_full_refresh_config):
    setup_responses()
    stream = LeverHiringStream(**test_full_refresh_config)
    inputs = {
        "response":
        requests.get("https://api.sandbox.lever.co/v0/example_endpoint")
    }
    expected_parsed_object = {
        "id": "fake_id",
        "name": "fake_name",
        "contact": "fake_contact",
        "headline": "Airbyte",
        "stage": "offer",
        "confidentiality": "non-confidential",
        "location": "Los Angeles, CA",
        "origin": "referred",
        "createdAt": 1628510997134,
        "updatedAt": 1628542848755,
        "isAnonymized": False,
    }
    assert next(stream.parse_response(**inputs)) == expected_parsed_object
Exemplo n.º 5
0
def test_backoff_time(patch_base_class, test_full_refresh_config):
    response_mock = MagicMock()
    stream = LeverHiringStream(**test_full_refresh_config)
    expected_backoff_time = None
    assert stream.backoff_time(response_mock) == expected_backoff_time
Exemplo n.º 6
0
def test_should_retry(patch_base_class, http_status, should_retry,
                      test_full_refresh_config):
    response_mock = MagicMock()
    response_mock.status_code = http_status
    stream = LeverHiringStream(**test_full_refresh_config)
    assert stream.should_retry(response_mock) == should_retry
Exemplo n.º 7
0
def test_http_method(patch_base_class, test_full_refresh_config):
    stream = LeverHiringStream(**test_full_refresh_config)
    expected_method = "GET"
    assert stream.http_method == expected_method