Example #1
0
 def __call__(self, *args):
     if self._called_count * 10 < self._num_responses:
         self._called_count += 1
         return MockResponse(
             datapath_args=["filings", "aapl_10q_filings.xml"])
     else:
         return MockResponse(text="")
Example #2
0
 def __call__(self, *args):
     if self._called_count * 10 < self._num_responses:
         self._called_count += 1
         return MockResponse(
             datapath_args=["filings", "aapl_10q_filings.xml"])
     else:
         return MockResponse(content=bytes("", "utf-8"))
Example #3
0
def mock_quarterly_quarter_directory(monkeymodule):
    """Mock directory of all filings for quarter.

    Use for QuarterlyFilings object.
    """
    monkeymodule.setattr(
        QuarterlyFilings, "_get_listings_directory",
        MockResponse(
            datapath_args=["filings", "master", "master_index_1993_QTR4.html"]))
Example #4
0
def mock_master_quarter_directory(monkeymodule):
    """Mock directory of all filings for quarter.

    Use for MasterFilings object.
    """
    monkeymodule.setattr(
        MasterFilings, "_get_listings_directory",
        lambda *args, **kwargs: MockResponse(datapath_args=[
            "filings", "master", "master_index_1993_QTR4.html"
        ]))
Example #5
0
def mock_master_idx_file(monkeypatch):
    monkeypatch.setattr(
        QuarterlyFilings, "_get_master_idx_file", lambda *args: MockResponse(
            datapath_args=["filings", "master", "master.idx"]).text)
Example #6
0
def mock_daily_quarter_directory(monkeymodule):
    """Mocks directory of all daily filings for quarter."""
    monkeymodule.setattr(
        DailyFilings, "_get_listings_directory",
        MockResponse(
            datapath_args=["filings", "daily", "daily_index_2018_QTR4.htm"]))
Example #7
0
def mock_single_cik_filing(monkeysession):
    """Returns mock response of filinghrefs for getting filing URLs."""
    monkeysession.setattr(
        NetworkClient, "get_response",
        MockResponse(datapath_args=["filings", "aapl_10q_filings.xml"]))
Example #8
0
def mock_filing_data(monkeysession):
    """Mock data from filing."""
    monkeysession.setattr(requests.Session, "get",
                          MockResponse(content=bytes("Testing...", "utf-8")))
Example #9
0
def mock_filing_data(monkeysession):
    """Mock data from filing."""
    monkeysession.setattr(
        requests, "get",
        lambda *args, **kwargs: MockResponse(text="Testing..."))
Example #10
0
def mock_single_cik_not_found(monkeymodule):
    """NetworkClient get_response method will return html with CIK not found message."""
    monkeymodule.setattr(
        NetworkClient, "get_response",
        MockResponse(datapath_args=["CIK", "cik_not_found.html"]))
Example #11
0
def mock_single_cik_filing(monkeymodule):
    """Returns mock response of filinghrefs for getting filing URLs."""
    monkeymodule.setattr(
        NetworkClient, "get_response", lambda *args, **kwargs: MockResponse(
            datapath_args=["filings", "aapl_10q_filings.xml"]))
Example #12
0
 def test_429_returns_custom_message(self, client, monkeypatch):
     # with pytest.raises(requests.exceptions.HTTPError) as e:
     response = client._validate_response(
         MockResponse(content=bytes("", "utf-8"), status_code=429))
     assert "rate limit" in response.reason
Example #13
0
 def test_client_bad_response_raises_error(self, client):
     no_cik_response = MockResponse(
         datapath_args=["CIK", "cik_not_found.html"])
     with pytest.raises(EDGARQueryError):
         client._validate_response(no_cik_response)
Example #14
0
def mock_single_filing_page_good_response(monkeypatch):
    monkeypatch.setattr(
        requests.Session, "get",
        MockResponse(datapath_args=["CIK", "single_filing_page.html"]))
Example #15
0
def mock_multiple_cik_results_good_response(monkeypatch):
    monkeypatch.setattr(
        requests.Session, "get",
        MockResponse(datapath_args=["CIK", "cik_multiple_results.html"]))
Example #16
0
def mock_single_filing_type_good_response(monkeypatch):
    """Mock response with list of single filing type for single CIK."""
    monkeypatch.setattr(
        requests.Session, "get",
        MockResponse(
            datapath_args=["CIK", "single_cik_multiple_filings_10k.html"]))