def test__push_ok():
    mock_response = Mock()
    mock_response.status_code = 200
    mock_response.headers = {"X-Ratelimit-Remaining": "1000"}
    mock_response.json.return_value = {}

    session = Mock()
    session.post.return_value = mock_response

    pb = PushBullet("apikey")
    pb._session = session

    server_response = pb._push({"key": "value"})

    session.post.assert_called_once_with(
        pb.PUSH_URL,
        data=json.dumps({"key": "value"}),
    )

    assert server_response == {
        "rate_limit": {
            "remaining": "1000",
            "limit": None,
            "reset": None,
        }
    }
def test__push_fail():
    mock_response = Mock()
    mock_response.status_code = 400

    session = Mock()
    session.post.return_value = mock_response

    pb = PushBullet("apikey")
    pb._session = session

    with pytest.raises(PushError):
        pb._push({"key": "value"})

    session.post.assert_called_once_with(
        pb.PUSH_URL,
        data=json.dumps({"key": "value"}),
    )