def test_validate_cik_after_cik_lookup(self, monkeypatch): # string remains unchecked until query to allow for possibility of # using company name, ticker, or CIK as string monkeypatch.setattr(NetworkClient, "get_response", MockSingleCIKNotFound) with pytest.raises(EDGARQueryError): _ = CIKLookup('0notvalid0').ciks
def test_filing_get_urls_returns_single_list_of_urls(self, monkeypatch): monkeypatch.setattr(_CIKValidator, "get_ciks", MockCIKValidatorMultipleCIKs.get_ciks) # Use same response for each request monkeypatch.setattr(NetworkClient, "get_response", MockSingleCIKFiling) ciks = CIKLookup(['aapl', 'msft', 'amzn']) f = Filing(ciks, FilingType.FILING_10Q, count=3) assert all(len(f.get_urls().get(key)) == 3 for key in f.get_urls().keys())
def test_validate_cik__is_string(self, bad_cik): with pytest.raises(TypeError): CIKLookup(bad_cik)
def test_multiple_results_raises_warnings( self, mock_single_cik_multiple_results_response): multiple_results_cik = CIKLookup('paper') with pytest.warns(UserWarning): _ = multiple_results_cik.ciks
def test_multiple_results_company_name_search( self, mock_single_cik_multiple_results_response): multiple_results_cik = CIKLookup('paper') with pytest.warns(UserWarning): assert len(multiple_results_cik.ciks) == 0
def test_cik_lookup_lookups_property(self): multiple_company_lookup = CIKLookup(['aapl', 'msft', 'fb']) assert multiple_company_lookup.lookups == ['aapl', 'msft', 'fb']
def test_cik_lookup_returns_correct_values(self, lookup, expected, mock_get_cik_map): look = CIKLookup(lookup) assert look.lookup_dict == expected
def test_validate_cik_after_cik_lookup(self, mock_single_cik_not_found): # string remains unchecked until query to allow for possibility of # using company name, ticker, or CIK as string with pytest.raises(EDGARQueryError): _ = CIKLookup('0notvalid0').ciks
def test_multiple_results_raises_warnings(self, monkeypatch): multiple_results_cik = CIKLookup('paper') monkeypatch.setattr(NetworkClient, "get_response", MockSingleCIKMultipleResultsResponse) with pytest.warns(UserWarning): _ = multiple_results_cik.ciks
def test_multiple_results_company_name_search(self, monkeypatch): multiple_results_cik = CIKLookup('paper') monkeypatch.setattr(NetworkClient, "get_response", MockSingleCIKMultipleResultsResponse) with pytest.warns(UserWarning): assert len(multiple_results_cik.ciks) == 0
def test_cik_lookup_returns_correct_values(self, monkeypatch): aapl = CIKLookup('aapl') monkeypatch.setattr(NetworkClient, "get_response", MockSingleCIKLookupResponse) assert aapl.ciks == ['0000320193']
def test_cik_lookup_returns_correct_values( self, mock_single_cik_lookup_response): aapl = CIKLookup('aapl') assert aapl.ciks == ['0000320193']
# https://github.com/coyo8/sec-edgar # pip install secedgar from secedgar.filings import CIKLookup, Filing, FilingType lookup = '0000320193' lookups = CIKLookup(['aapl', 'msft', 'Facebook']) my_filings = Filing(cik_lookup=lookup, filing_type=FilingType.FILING_10Q) my_filings.save('tempdir')
def test_validate_cik__is_string(self, bad_cik, expected): # float and int not accepted, raising TypeError with expected: CIKLookup(bad_cik)