Ejemplo n.º 1
0
def test_request_headers(patch_base_class):
    stream = NotionStream(config=MagicMock())
    inputs = {
        "stream_slice": None,
        "stream_state": None,
        "next_page_token": None
    }
    expected_headers = {"Notion-Version": "2021-08-16"}
    assert stream.request_headers(**inputs) == expected_headers
Ejemplo n.º 2
0
def test_request_params(patch_base_class):
    stream = NotionStream(config=MagicMock())
    inputs = {
        "stream_slice": None,
        "stream_state": None,
        "next_page_token": None
    }
    expected_params = {}
    assert stream.request_params(**inputs) == expected_params
Ejemplo n.º 3
0
def test_parse_response(patch_base_class, requests_mock):
    stream = NotionStream(config=MagicMock())
    requests_mock.get("https://dummy",
                      json={"results": [{
                          "a": 123
                      }, {
                          "b": "xx"
                      }]})
    resp = requests.get("https://dummy")
    inputs = {"response": resp, "stream_state": MagicMock()}
    expected_parsed_object = [{"a": 123}, {"b": "xx"}]
    assert list(stream.parse_response(**inputs)) == expected_parsed_object
Ejemplo n.º 4
0
def test_backoff_time(patch_base_class):
    response_mock = MagicMock()
    stream = NotionStream(config=MagicMock())
    expected_backoff_time = None
    assert stream.backoff_time(response_mock) == expected_backoff_time
Ejemplo n.º 5
0
def test_should_retry(patch_base_class, http_status, should_retry):
    response_mock = MagicMock()
    response_mock.status_code = http_status
    stream = NotionStream(config=MagicMock())
    assert stream.should_retry(response_mock) == should_retry
Ejemplo n.º 6
0
def test_http_method(patch_base_class):
    stream = NotionStream(config=MagicMock())
    expected_method = "GET"
    assert stream.http_method == expected_method
Ejemplo n.º 7
0
def test_next_page_token(patch_base_class, requests_mock):
    stream = NotionStream(config=MagicMock())
    requests_mock.get("https://dummy", json={"next_cursor": "aaa"})
    inputs = {"response": requests.get("https://dummy")}
    expected_token = {"next_cursor": "aaa"}
    assert stream.next_page_token(**inputs) == expected_token