def __init__(self, instelling: Instelling, ruimte: Ruimte):
     self._instelling = instelling
     self._radiator_temperatuur_sensor = ruimte.get_radiator().get_sensor()
     self._airco_temperatuur_sensor = ruimte.get_airco().get_sensor()
     self._temperatuur_sensor = ruimte.get_temperatuur_sensor()
     self._humiditeit_sensor = ruimte.get_humiditeit_sensor()
     self._beweging_sensor = ruimte.get_beweging_sensor()
Esempio n. 2
0
    def test_create_from_json_all_params(self):
        test_json = '{"id": 1, "naam": "4.13", "personenCapaciteit": 10, "radiator": {"id": 2, "verbruik": 100, ' \
                    '"verbruikType": "KUBIEKE_METER_GAS", "temperatuurSensor": {"id": 4, "sensorInstelling": {"' \
                    'id": 1, "meetIntervalSec": 3600, "opslaanIntervalSec": 3600}, "type": "MCP9808"}}, "airco":' \
                    ' {"id": 1, "verbruik": 100, "verbruikType": "KILOWATTUUR", "temperatuurSensor": {"id": 1, "' \
                    'sensorInstelling": {"id": 1, "meetIntervalSec": 3600, "opslaanIntervalSec": 3600}, "type": "' \
                    'MCP9808"}}, "temperatuurSensor": {"id": 5, "sensorInstelling": {"id": 1, "meetIntervalSec": ' \
                    '3600, "opslaanIntervalSec": 3600}, "type": "DHT22"}, "humiditeitSensor": {"id": 2, "sensorI' \
                    'nstelling": {"id": 1, "meetIntervalSec": 3600, "opslaanIntervalSec": 3600}, "type": "DHT22"}' \
                    ', "motionSensor": {"id": 3, "sensorInstelling": {"id": 1, "meetIntervalSec": 3600, "opslaanI' \
                    'ntervalSec": 3600}, "type": "PIR"}}'

        sut = Ruimte()

        sut.create_from_json(json.loads(test_json))

        self.assertEqual(sut.get_naam(), "4.13")
        self.assertIsInstance(sut.get_radiator(), KlimaatBeheerApparaat)
        self.assertIsInstance(sut.get_airco(), KlimaatBeheerApparaat)
        self.assertIsInstance(sut.get_temperatuur_sensor(), Sensor)
        self.assertIsInstance(sut.get_humiditeit_sensor(), Sensor)
        self.assertIsInstance(sut.get_beweging_sensor(), Sensor)