コード例 #1
0
 def testDoesPDFAlreadyExist(self):
   remove_data('plot_x_vs_y.pdf')
   plot_x_vs_y(get_trips_and_weather(),'Annual Member','Min_TemperatureF',
       'plot_x_vs_y')
   result = plot_x_vs_y(get_trips_and_weather(),'Annual Member',
       'Min_TemperatureF','plot_x_vs_y')
   self.assertTrue(result)
 def test_file_present(self):
     remove_data("open_data_year_one.zip")
     get_pronto_data()
     result = download_if_needed(
         "https://s3.amazonaws.com/pronto-data/open_data_year_one.zip", "open_data_year_one.zip"
     )
     self.assertEqual("open_data_year_one.zip already exists", result)
コード例 #3
0
 def testCache(self):
     #1
     if not os.path.isdir('__pycache__'):
         os.makedirs('__pycache__')
     result=remove_data()
     expected_explanation='Cache and/or .zip folder successfully deleted.'
     self.assertEqual(result, expected_explanation)
コード例 #4
0
 def testNoCache(self):
     #1
     if os.path.isdir('__pycache__'):
         shutil.rmtree('__pycache__')
     result=remove_data()
     expected_explanation='No cache or .zip folder detected.'
     self.assertEqual(result, expected_explanation)
コード例 #5
0
        def testRemoveData(self):
            """
            Test the remove_data function by seeing if the data was deleted
            from the directory
            """

            remove_data()
            cwd = os.getcwd()
            path = cwd + '\open_data_year_one.zip'

            # the zip file
            self.assertFalse(os.path.exists(path))

            # individual .csv and .txt files uncase unzipped
            self.assertFalse(os.path.exists(cwd + '\\2015_station_data.csv'))
            self.assertFalse(os.path.exists(cwd + '\\2015_status_data.csv'))
            self.assertFalse(os.path.exists(cwd + '\\2015_trip_data.csv'))
            self.assertFalse(os.path.exists(cwd + '\\2015_weather_data.csv'))
            self.assertFalse(os.path.exists(cwd + '\README.txt'))
コード例 #6
0
 def testWasPDFCreated(self):
     remove_data('plot_x_vs_y.pdf')
     plot_x_vs_y(get_trips_and_weather(),'Annual Member','Min_TemperatureF',
         'plot_x_vs_y')
     self.assertTrue(os.path.exists('plot_x_vs_y.pdf'))
コード例 #7
0
 def test_remove_data_withoutfile(self):
   # if the file does not exist this should pass and the previous test fail
   result = remove_data()
   self.assertEqual(6,result)
コード例 #8
0
 def test_remove_data_withfile(self):
   # if the file exists, this should pass next test should fail
   result = remove_data()
   self.assertEqual(5,result)
 def test_file_notpresent(self):
     os.remove("open_data_year_one.zip")
     result = remove_data("open_data_year_one")
     self.assertEqual(result, "No such data file exists that can be removed")
 def test_file_removal(self):
     download_if_needed("https://s3.amazonaws.com/pronto-data/open_data_year_one.zip", "open_data_year_one.zip")
     result = remove_data("open_data_year_one.zip")
     self.assertEqual(result, "Data file removed")
 def test_url_nonexistent(self):
     remove_data("open_data_year_one.zip")
     result = download_if_needed(
         "https://s3.amazonaws.com/pronto-data/open_data_year_ne.zip", "open_data_year_one.zip"
     )
     self.assertEqual("Url does not exist", result)