Example #1
0
    def test_empty_dataframe(self):
        with open('crawlclima/redemet/tests/'
                  'example_with_no_record.txt', 'r') as fd:
            dataframe = parse_page(fd.read())

        summary = describe(dataframe)
        self.assertEqual(summary, {})
Example #2
0
    def test_with_empty_data(self):
        with open('crawlclima/redemet/tests/'
                  'example_with_no_record.txt', 'r') as fd:
            dataframe = parse_page(fd.read())

        self.assertIsInstance(dataframe, pd.DataFrame)
        self.assertTrue(dataframe.empty)
Example #3
0
 def test_with_data(self):
     with open('crawlclima/tests/test_data/example_data.txt', 'r') as fd:
         dataframe = parse_page(fd.read())
     self.assertEqual(
         dataframe.observation_time[0].to_pydatetime(),
         datetime(2015, 2, 28, 0, 0),
     )
     self.assertAlmostEqual(dataframe.temperature.mean(), 27.75, 2)
Example #4
0
    def test_filled_dataframe(self):
        with open('crawlclima/redemet/tests/example_data.txt', 'r') as fd:
            dataframe = parse_page(fd.read())

        summary = describe(dataframe)
        self.assertEqual(summary, {
            'humidity_max': 88.679561374670186,
            'humidity_mean': 73.687275217443982,
            'humidity_min': 55.321861254558726,
            'pressure_max': 1014.0,
            'pressure_mean': 1010.9583333333334,
            'pressure_min': 1008.0,
            'temperature_max': 31.0,
            'temperature_mean': 27.75,
            'temperature_min': 25.0
        })
Example #5
0
    def test_filled_dataframe(self):
        with open("crawlclima/redemet/tests/example_data.txt", "r") as fd:
            dataframe = parse_page(fd.read())

        summary = describe(dataframe)
        self.assertEqual(
            summary,
            {
                "humidity_max": 88.679561374670186,
                "humidity_mean": 73.687275217443982,
                "humidity_min": 55.321861254558726,
                "pressure_max": 1014.0,
                "pressure_mean": 1010.9583333333334,
                "pressure_min": 1008.0,
                "temperature_max": 31.0,
                "temperature_mean": 27.75,
                "temperature_min": 25.0,
            },
        )
Example #6
0
 def test_includes_humidity(self):
     with open('crawlclima/tests/test_data/example_data.txt', 'r') as fd:
         dataframe = parse_page(fd.read())
     self.assertAlmostEqual(dataframe.humidity.min(), 55.32, 2)
Example #7
0
 def test_skip_SPECI_entries(self):
     with open('crawlclima/tests/test_data/example_data.txt', 'r') as fd:
         dataframe = parse_page(fd.read())
     self.assertEqual(len(dataframe), 24)
Example #8
0
 def test_skip_SPECI_entries(self):
     with open("crawlclima/redemet/tests/example_data.txt", "r") as fd:
         dataframe = parse_page(fd.read())
     self.assertEqual(len(dataframe), 24)
 def test_includes_humidity(self):
     with open('crawlclima/redemet/tests/example_data.txt', 'r') as fd:
         dataframe = parse_page(fd.read())
     self.assertAlmostEqual(dataframe.humidity.min(), 55.32, 2)
 def test_with_data(self):
     with open('crawlclima/redemet/tests/example_data.txt', 'r') as fd:
         dataframe = parse_page(fd.read())
     self.assertEqual(dataframe.observation_time[0].to_pydatetime(),
                      datetime(2015, 2, 28, 0, 0))
     self.assertAlmostEqual(dataframe.temperature.mean(), 27.75, 2)
 def test_skip_SPECI_entries(self):
     with open('crawlclima/redemet/tests/example_data.txt', 'r') as fd:
         dataframe = parse_page(fd.read())
     self.assertEqual(len(dataframe), 24)