def test_getPricesForDate(self): date_price_obj = mock.Mock() date_price_obj.date = "11-02" date_price_obj.price = 69 objs = [date_price_obj, date_price_obj, date_price_obj] prices_for_date = APIStockParser.getPricesForDate('02', '11', objs) self.assertEquals(prices_for_date[2], 69)
def test_median(self): num_lst = [1,2,3,4,5] self.assertEquals(APIStockParser.median(num_lst), 3)
def test_stepper(self): steps = APIStockParser.stepper(1, 4, 1) self.assertEquals(steps.next(), 1) self.assertEquals(steps.next(), 2) steps.next() self.assertEquals(steps.next(), 4)
def test_average(self): num_set = [2, 2, 2] self.assertEquals(APIStockParser.average(num_set), 2)
def test_get_date(self): FakeDateTime.now = classmethod(lambda cls: DateTime.datetime(2010, 1, 1)) self.assertEquals(APIStockParser.get_date(), "01-01-2010") self.assertEquals(APIStockParser.get_date(addDays=5), "06-01-2010")