def test_no_filings_available(self): mock_filing_getter = mock.Mock() mock_filing_getter.get_filing.side_effect = NoFilingsNotAvailable() getter = AccountingMetricGetter(metric=mock.Mock(), filing_getter=mock_filing_getter) with self.assertRaises(NoDataForStockForRange) as cm: getter.get_data(symbol=None, date=datetime.date(2012, 12, 1)) self.assertIsNone(cm.exception.start) self.assertIsNone(cm.exception.end)
def test_filing_not_available_until(self): mock_filing_getter = mock.Mock() end_date = datetime.date(2012, 12, 1) mock_filing_getter.get_filing.side_effect = FilingNotAvailableForDate(message='', end=end_date) getter = AccountingMetricGetter(metric=mock.Mock(), filing_getter=mock_filing_getter) with self.assertRaises(NoDataForStockForRange) as cm: getter.get_data(symbol=None, date=datetime.date(2012, 12, 1)) self.assertEqual(cm.exception.end, end_date)
def test_metric_not_in_filing(self): mock_filing_getter = mock.Mock() mock_filing = mock.Mock() mock_filing.date = datetime.date(2012, 11, 30) mock_filing.next_filing = None mock_filing_getter.get_filing.return_value = mock_filing mock_metric = mock.Mock() mock_metric.value_from_filing.side_effect = ValueNotInFilingDocument() getter = AccountingMetricGetter(metric=mock_metric, filing_getter=mock_filing_getter) with self.assertRaises(NoDataForStockForRange): getter.get_data(symbol='ABC', date=datetime.datetime(2012, 12, 1))
def test_google_boundry(self): quarterly_eps = EPS.quarterly() getter = AccountingMetricGetter(metric=quarterly_eps, filing_getter=HTMLEdgarDriver) date = datetime.date(2013, 4, 25) #Google filed on this date. interval_start, _, _ = getter.get_data(symbol='goog', date=date) self.assertEqual(interval_start, datetime.date(2012, 10, 31))
def test_google(self): quarterly_eps = EPS.quarterly() getter = AccountingMetricGetter(metric=quarterly_eps, filing_getter=HTMLEdgarDriver) date = datetime.date(2013, 1, 2) interval_start, earnings, interval_end = getter.get_data(symbol="goog", date=date) self.assertEqual(interval_start, datetime.date(2012, 10, 31)) self.assertEqual(interval_end, datetime.date(2013, 4, 25)) self.assertEqual(earnings, 6.53)
def test_google(self): getter = AccountingMetricGetter(metric=QuarterlyEPS, filing_getter=HTMLEdgarDriver) date = datetime.date(2013, 1, 2) interval_start, earnings, interval_end = getter.get_data(symbol='goog', date=date) self.assertEqual(interval_start, datetime.date(2012, 10, 30)) self.assertEqual(interval_end, datetime.date(2013, 4, 25)) self.assertEqual(earnings, 6.53)
def test_google_boundry(self): getter = AccountingMetricGetter(metric=QuarterlyEPS, filing_getter=HTMLEdgarDriver) date = datetime.date(2013, 4, 25) #Google filed on this date. interval_start, _, _ = getter.get_data(symbol='goog', date=date) self.assertEqual(interval_start, datetime.date(2012, 10, 30))