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="")
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"))
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"]))
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" ]))
def mock_master_idx_file(monkeypatch): monkeypatch.setattr( QuarterlyFilings, "_get_master_idx_file", lambda *args: MockResponse( datapath_args=["filings", "master", "master.idx"]).text)
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"]))
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"]))
def mock_filing_data(monkeysession): """Mock data from filing.""" monkeysession.setattr(requests.Session, "get", MockResponse(content=bytes("Testing...", "utf-8")))
def mock_filing_data(monkeysession): """Mock data from filing.""" monkeysession.setattr( requests, "get", lambda *args, **kwargs: MockResponse(text="Testing..."))
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"]))
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"]))
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
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)
def mock_single_filing_page_good_response(monkeypatch): monkeypatch.setattr( requests.Session, "get", MockResponse(datapath_args=["CIK", "single_filing_page.html"]))
def mock_multiple_cik_results_good_response(monkeypatch): monkeypatch.setattr( requests.Session, "get", MockResponse(datapath_args=["CIK", "cik_multiple_results.html"]))
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"]))