Beispiel #1
0
 def test_remove(self):
     HW4.download_if_needed('http://s3.amazonaws.com/pronto-data/open_data_year_one.zip', 
                               'open_data_year_one.zip')
     #before remove_data, data are present
     self.assertTrue(os.path.exists('open_data_year_one.zip'))
     HW4.remove_data()
     #after remove_data, data are not present
     self.assertFalse(os.path.exists('open_data_year_one.zip'))
Beispiel #2
0
 def test_download(self):
     HW4.get_pronto_data()
     if os.path.exists('daily_totals.png'):
         os.remove('daily_totals.png')
     #before plot no png flile
     self.assertFalse(os.path.exists('daily_totals.png'))
     HW4.plot_daily_totals()
     #after plot, png file is present
     self.assertTrue(os.path.exists('daily_totals.png')) 
Beispiel #3
0
 def test_download(self):
     #test when data are not present
     HW4.remove_data()
     #test when the url is not valid
     with self.assertRaises(urllib3.exceptions.MaxRetryError):
         HW4.download_if_needed('http://s3.23amazonaws.com/pronto-data/open_data_year_one.zip', 
                               'open_data_year_one.zip')
     #test when url is valid
     HW4.download_if_needed('http://s3.amazonaws.com/pronto-data/open_data_year_one.zip', 
                               'open_data_year_one.zip')
     self.assertTrue(os.path.exists('open_data_year_one.zip'))
     #test when data are present
     out = HW4.download_if_needed('http://s3.amazonaws.com/pronto-data/open_data_year_one.zip', 
                               'open_data_year_one.zip')
     assert out == 'open_data_year_one.zip already exists'   
Beispiel #4
0
 def test11(self):
     #with self.assertRaises(TypeError):
     self.assertEqual(HW4.full_name_generator(['h','i'],'burger'),'hiburger')
Beispiel #5
0
 def test12(self):
     self.assertEqual(HW4.full_name_generator('cheese','burger'),'cheeseburger')
Beispiel #6
0
 def test10(self):
     #with self.assertRaises(TypeError):
     self.assertEqual(HW4.full_name_generator('2',3),'23')
Beispiel #7
0
 def test1(self):
     #with self.assertRaises(AssertionError):
     self.assertEqual(HW4.find_cube_volume(-2),8)
Beispiel #8
0
 def test8(self):
     self.assertEqual(HW4.list_average([4,4,4,4]),4)
Beispiel #9
0
 def test9(self):
     #with self.assertRaises(AssertionError):
     self.assertEqual(HW4.full_name_generator(1,2),'12')
Beispiel #10
0
 def test_two(self):
     self.assertEqual(HW4.cube('h'), "Type Error")
     self.assertEqual(HW4.cube('five'), "Type Error")
     self.assertEqual(HW4.cube([5, -5]), "Type Error")
Beispiel #11
0
 def test_one(self):
     self.assertEqual(HW4.avg([]), "Zero Division")
     self.assertEqual(HW4.avg([-5]), -5)
     self.assertEqual(HW4.avg([5]), 5)
Beispiel #12
0
 def test4(self):
     self.assertEqual(HW4.find_cube_volume(2),8)
Beispiel #13
0
 def test5(self):
     #with self.assertRaises(ZeroDivisionError):
     self.assertEqual(HW4.list_average([]),2)
Beispiel #14
0
 def test3(self):
     #with self.assertRaises(TypeError):
     self.assertEqual(HW4.find_cube_volume("2"),8)
Beispiel #15
0
 def test_three(self):
     self.assertEqual(HW4.avg([1, 3]), 2)
     self.assertEqual(HW4.avg([3, 5, 7]), 5)
     self.assertEqual(HW4.avg([-3, -7, -5]), -5)
Beispiel #16
0
 def test_two(self):
     self.assertEqual(HW4.avg('five'), "Type Error")
     self.assertEqual(HW4.avg(0), "Type Error")
     self.assertEqual(HW4.avg('0'), "Type Error")
Beispiel #17
0
 def test2(self):
     #with self.assertRaises(AssertionError):
     self.assertEqual(HW4.find_cube_volume(complex(2,3)),8)
Beispiel #18
0
 def test_one(self):
     self.assertEqual(HW4.cube(5), 125)
     self.assertEqual(HW4.cube(3), 27)
     self.assertEqual(HW4.cube(0), 0)
Beispiel #19
0
 def test6(self):
     #with self.assertRaises(TypeError):
     self.assertEqual(HW4.list_average(),0)
Beispiel #20
0
 def test_three(self):
     self.assertEqual(HW4.cube(-5), "Negative Edge Length")
     self.assertEqual(HW4.cube(complex(3, 5)), "Complex Edge Length")
     self.assertEqual(HW4.cube(complex(-3, -5)), "Complex Edge Length")
Beispiel #21
0
 def test7(self):
     #with self.assertRaises(TypeError):
     self.assertEqual(HW4.list_average(['4',4,4,4]),2)
Beispiel #22
0
import HW4 as Cls

PROB = 0.4
TIME_STEPS = 20
Realization_times = 1000

myGame = Cls.Games(realization_times=Realization_times, prob=PROB)

# simulate
myGame.simulate(TIME_STEPS)

# print
print(myGame.get_ave_exp_cost())
print(myGame.get_total_time())