Esempio n. 1
0
    def test_low_border_values(self):
        """
        Test that a grid cell can be created without error using low border
        values for all three variables, namely 0 for temperature, humidity,
        and albedo.
        """
        cell = GridCell(0, 0, 0)

        self.assertEqual(cell.get_temperature(), 0)
        self.assertEqual(cell.get_relative_humidity(), 0)
        self.assertEqual(cell.get_albedo(), 0)
Esempio n. 2
0
    def test_high_border_values(self):
        """
        Test that a grid cell can be created without error using high border
        values for all three variables, using 100 for humidity and 1 for
        albedo. Temperature has no high border.
        """
        cell = GridCell(987654321, 100, 1)

        self.assertEqual(cell.get_temperature(), 987654321)
        self.assertEqual(cell.get_relative_humidity(), 100)
        self.assertEqual(cell.get_albedo(), 1)
Esempio n. 3
0
    def test_invalid_humidity_change(self):
        """
        Test that an error is raised when a grid cell's relative humidity is
        changed to an invalid value after the cell is instantiated. Also
        ensures that the grid cell's humidity is unchanged after the attempt.
        """
        cell = GridCell(273.15, 65, 0.6)

        with self.assertRaises(ValueError):
            cell.set_relative_humidity(-0.01)

        with self.assertRaises(ValueError):
            cell.set_relative_humidity(100.1)

        self.assertEqual(cell.get_relative_humidity(), 65)
Esempio n. 4
0
    def test_valid_init(self):
        """
        Test error-free creation of a valid grid cell, and proper returns from
        getter methods.
        """
        temp = 1
        r_hum = 75
        albedo = 1

        cell = GridCell(temp, r_hum, albedo)

        self.assertEqual(cell.get_temperature(), temp)
        self.assertEqual(cell.get_relative_humidity(), r_hum)
        self.assertEqual(cell.get_albedo(), albedo)
        self.assertEqual(cell.get_temperature_change(), 0)