Exemplo n.º 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)
Exemplo n.º 2
0
    def test_invalid_plot_no_file(self):
        """
        Here we check that the pdf file is NOT generated
        when a valid data frame, but an invalid column
        are supplied to the function.
        """

        data = get_trips_and_weather()

        fileName = 'Temp_and_Membership_invalid'
        plot_x_vs_y(data,'Mean_Temperaturezzzz_F','Annual Member', fileName)
        filePath = os.getcwd() + '\\' + fileName + '.pdf'
        self.assertFalse(os.path.exists(filePath))
Exemplo n.º 3
0
    def test_invalid_plot_exception_trhown(self):
        """
        Here we check that a TypeError exception is
        thrown when a valid data frame, but an invalid
        column are supplied to the function.
        """

        data = get_trips_and_weather()

        fileName = 'Temp_and_Membership_invalid'
        plot_x_vs_y(data,'Mean_Temperaturezzzz_F','Annual Member', fileName)
        filePath = os.getcwd() + '\\' + fileName + '.pdf'
        #self.assertFalse(os.path.exists(filePath))
        self.assertRaises(KeyError)
Exemplo n.º 4
0
    def test_valid_plot(self):
        """
        Here we check that the pdf file is properly generated
        when a valid data frame and columns are supplied as
        arguments to the function.
        """

        # download the trip and weather data
        # NOTE: we turn off alerts about whether or not data
        # has already been downloaded within the pronto_utils.py
        # code in order to make unit test output cleaner
        data = get_trips_and_weather()

        fileName = 'Temp_and_Membership'
        plot_x_vs_y(data,'Mean_Temperature_F','Annual Member', fileName)
        filePath = os.getcwd() + '\\' + fileName + '.pdf'
        self.assertTrue(os.path.exists(filePath))
Exemplo n.º 5
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'))
Exemplo n.º 6
0
 def testAlreadyExists(self):
     # 1
     data = pd.read_csv("fake_data.csv")
     data = pd.read_csv("fake_data.csv")
     result = plot_x_vs_y(data, "fakex", "fakey", "fakeplot.png")
     self.assertTrue(result[2])
Exemplo n.º 7
0
 def testNewPlot(self):
     # 1
     remove_data("fakeplot.png")
     data = pd.read_csv("fake_data.csv")
     result = plot_x_vs_y(data, "fakex", "fakey", "fakeplot.png")
     self.assertFalse(result[2])
Exemplo n.º 8
0
 def testGoodFileName(self):
     # 1
     data = pd.read_csv("fake_data.csv")
     result = plot_x_vs_y(data, "fakex", "fakey", "fakeplot.png")
     self.assertTrue(result[1])
Exemplo n.º 9
0
 def testPlotSuccessful(self):
     # 1
     remove_data("fakeplot.png")
     data = pd.read_csv("fake_data.csv")
     result = plot_x_vs_y(data, "fakex", "fakey", "fakeplot.png")
     self.assertTrue(result[0])
Exemplo n.º 10
0
 def testEmptyDataFrame(self):
     #Make fake data frame to test code
     data = []
     result = plot_x_vs_y(data, 'A', 'B', 'a_vs_b')
     expected_result = 'Please enter valid data frame.'
     self.assertEqual(result, expected_result)
Exemplo n.º 11
0
 def testColumnNames(self):
     #Make fake data frame to test code
     data = pd.DataFrame(np.random.randn(1000, 2), columns=['A', 'B'])
     result = plot_x_vs_y(data, 'Apple', 'B', 'a_vs_b')
     expected_result = 'Please verify column names are correct.'
     self.assertEqual(result, expected_result)
Exemplo n.º 12
0
 def testPlotSaves(self):
     #Make fake data frame to test code
     data = pd.DataFrame(np.random.randn(1000, 2), columns=['A', 'B'])
     result = plot_x_vs_y(data, 'A', 'B', 'a_vs_b')
     expected_result = 'Figure a_vs_b successfully saved.'
     self.assertEqual(result, expected_result)