def test_params_reset_after_get_cik(self, ticker_lookups, mock_client_cik_lookup, mock_single_cik_lookup_outside_map): lookup = CIKLookup(lookups=ticker_lookups, client=mock_client_cik_lookup) lookup._get_cik_from_html(ticker_lookups[0]) assert lookup.params.get("CIK") is None and lookup.params.get( "company") is None
def test_multiple_results_raises_warnings( self, mock_client_cik_lookup, mock_single_cik_multiple_results_response): multiple_results_cik = CIKLookup('paper', client=mock_client_cik_lookup) with pytest.warns(UserWarning): _ = multiple_results_cik.ciks
def test_multiple_results_company_name_search( self, mock_client_cik_lookup, mock_single_cik_multiple_results_response): multiple_results_cik = CIKLookup('paper', client=mock_client_cik_lookup) with pytest.warns(UserWarning): assert len(multiple_results_cik.ciks) == 0
def test_empty_lookups_raises_type_error(self, bad_lookups): with pytest.raises(TypeError): CIKLookup(lookups=bad_lookups)
def test_client_property(self, client, ticker_lookups): lookup = CIKLookup(ticker_lookups, client=client) assert lookup.client == client
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_validate_cik__is_string(self, bad_cik): with pytest.raises(TypeError): CIKLookup(bad_cik)
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_lookups_property(self, mock_client_cik_lookup): multiple_company_lookup = CIKLookup(['aapl', 'msft', 'fb'], client=mock_client_cik_lookup) assert multiple_company_lookup.lookups == ['aapl', 'msft', 'fb']
def test_validate_cik_on_bad_ciks(self, bad_cik): with pytest.raises(CIKError): CIKLookup._validate_cik(bad_cik)
def test_cik_lookup_cik_hits_request(self): with patch.object(CIKLookup, '_get_cik_from_html') as mock: CIKLookup(['Apple']).get_ciks() mock.assert_called()
def test_lookups_property(self, mock_client_cik_lookup, ticker_lookups): lookup = CIKLookup(lookups=ticker_lookups, client=mock_client_cik_lookup) assert lookup.lookups == ticker_lookups
def test_bad_lookups_raises_type_error(self, bad_lookups, mock_client_cik_lookup): with pytest.raises(TypeError): CIKLookup(lookups=bad_lookups, client=mock_client_cik_lookup)
def test_validate_cik__is_string(self, mock_client_cik_lookup, bad_cik): with pytest.raises(TypeError): CIKLookup(bad_cik, client=mock_client_cik_lookup)
def test_lookups_property(self, ticker_lookups): lookup = CIKLookup(lookups=ticker_lookups) assert lookup.lookups == ticker_lookups
def test_cik_lookup_cik_bypasses_request(self): with patch.object(CIKLookup, '_get_cik_from_html') as mock: CIKLookup(['1018724']).get_ciks() mock.assert_not_called()
def test_validate_lookup(self, bad_lookup): with pytest.raises(TypeError): CIKLookup._validate_lookup(bad_lookup)
def test_cik_lookup_returns_correct_values(self, lookup, expected, mock_get_cik_map): look = CIKLookup(lookup) assert look.lookup_dict == expected
def cik_lookup(self, val): if not isinstance(val, CIKLookup): val = CIKLookup(val) self._cik_lookup = val
def test_cik_lookup_returns_correct_values_smoke(self, lookup, expected, real_test_client): look = CIKLookup(lookup, client=real_test_client) assert look.lookup_dict == expected