Exemplo n.º 1
0
class Test(unittest.TestCase):
    horseOdds = None
    

    def setUp(self):
        self.horseOdds = HorseOdds () 


    def tearDown(self):
        pass


    def testSetHorseName(self):
        self.horseOdds.setHorseName("dave")
        self.assertEquals(self.horseOdds.getHorseName(), "dave", "testfailed") 
        
    def testSetHorseOddsDecimal(self):
        self.horseOdds.setHorseOddsString("11/2")
        self.assertEquals(self.horseOdds.getHorseOddsDecimal(),5.50, "testfailed")     
     
    def testSetHorseOddsString(self):
        self.horseOdds.setHorseOddsString("11/2")
        self.assertEquals(self.horseOdds.getHorseOddsString(),"11/2", "testfailed")    
        
    def testSetHorseOddsNumber(self):
        self.horseOdds.setHorseNumber(10)
        self.assertEquals(self.horseOdds.getHorseNumber(),10, "testfailed")
        
    def testToString(self):
        self.horseOdds.setHorseNumber(10)
        self.horseOdds.setHorseOddsString("11/2")
        self.horseOdds.setHorseName("dave")
        self.assertEquals(self.horseOdds.toString(), "10 dave                                       11/2", "test failed")
Exemplo n.º 2
0
 def readCsv(self):  
     #print (os.getcwd())
     horseOddsArray = []
     with open("horse_name_and_odds.csv") as infile:
         reader = csv.reader(infile)
         for row in reader:
             horseOddsRow = HorseOdds ()
             horseOddsRow.setHorseOddsString(row[2])
             horseOddsRow.setHorseName(row[1])
             horseOddsRow.setHorseNumber(row[0])
             #print (horseOddsRow.toString())
             horseOddsArray.append(horseOddsRow)
             
     return (horseOddsArray)