def setUp(self): """ Setup work before each test """ self.all_stocks = stocks.StockCollection() sa.LoadCSV(TEST_FILES["march1.csv"], self.all_stocks) sa.LoadCSV(TEST_FILES["march2.csv"], self.all_stocks) sa.LoadCSV(TEST_FILES["march3.csv"], self.all_stocks) sa.LoadCSV(TEST_FILES["march4.csv"], self.all_stocks) sa.LoadCSV(TEST_FILES["march5.csv"], self.all_stocks) sa.LoadTriplet(TEST_FILES["feb1.trp"], self.all_stocks) sa.LoadTriplet(TEST_FILES["feb2.trp"], self.all_stocks) sa.LoadTriplet(TEST_FILES["feb3.trp"], self.all_stocks) sa.LoadTriplet(TEST_FILES["feb4.trp"], self.all_stocks)
def test_simple_case(self): """ Large file test that LoadTriplet is correct """ loadTriplet = sa.LoadTriplet(TEST_FILES['feb1.trp'], self.all_stocks) stocks_loaded = self.all_stocks._all_stocks.keys() self.assertEqual(len(stocks_loaded), 1878, 'LoadTriplet should load correct number of stocks')
def setUp(self): """ Setup work before each test """ self.all_stocks = stocks.StockCollection() sa.LoadTriplet(TEST_FILES['feb1_small.trp'], self.all_stocks)
def test_invalid_file(self): """ Test program raises appropriate exceptions """ with self.assertRaises(RuntimeError): # This is an invalid Triplet file and should not work sa.LoadTriplet('stocks.py', self.all_stocks)
def test_process_overriden(self): """ [OOC 4] Demonstrated correct understanding of overriding methods """ loadTriplet = sa.LoadTriplet(TEST_FILES['feb1.trp'], self.all_stocks) with open(TEST_FILES['feb1.trp'], 'r') as f: loadTriplet._process(f)
def test_inheritance(self): """ [OOC 3] Demonstrated correct understanding of inheritance """ loadTriplet = sa.LoadTriplet(TEST_FILES['feb1.trp'], self.all_stocks) self.assertEqual(loadTriplet.__class__.__bases__[0].__name__, 'Loader', 'LoadTriplet should correctly inherit from Loader')