def test_getProperty_existing_cached(self):
        # time+0 seconds
        with now_is('2000-01-01 00:00:00'):
            self.service.getProperty("someprop")
            self.service.getProperty("someprop")

        # time+30 seconds
        with now_is('2000-01-01 00:00:30'):
            self.service.getProperty("someprop")

        self.assertEqual(self.oauth_mock.get.call_count, 1)
        self.oauth_mock.get.assert_called_once_with(
            '/equipment/installations/[id]/gateways/[serial]/devices/[device]/features/'
        )

        # time+70 seconds (must be more than CACHE_DURATION)
        with now_is('2000-01-01 00:01:10'):
            self.service.getProperty("someprop")

        self.assertEqual(self.oauth_mock.get.call_count, 2)
    def test_setProperty_invalidateCache(self):
        # freeze time
        with now_is('2000-01-01 00:00:00'):
            self.assertEqual(self.service.is_cache_invalid(), True)
            self.service.getProperty("someprop")
            self.assertEqual(self.service.is_cache_invalid(), False)

            self.service.setProperty("someotherprop", "doaction",
                                     {'name': 'abc'})
            self.assertEqual(self.service.is_cache_invalid(), True)

            self.service.getProperty("someprop")
            self.assertEqual(self.oauth_mock.get.call_count, 2)
Esempio n. 3
0
 def test_getDomesticHotWaterActiveMode_10_10_time(self):
     with now_is('2000-01-01 10:10:00'):
         self.assertEqual(self.device.getDomesticHotWaterActiveMode(),
                          'normal')
Esempio n. 4
0
 def test_getDomesticHotWaterDesiredTemperature_fri_20_00_time(self):
     with now_is('2021-09-10 20:00:00'):
         self.assertEqual(
             self.device.getDomesticHotWaterDesiredTemperature(), 50)
Esempio n. 5
0
 def test_getDomesticHotWaterActiveMode_fri_10_10_time(self):
     with now_is('2021-09-10 10:10:00'):
         self.assertEqual(self.device.getDomesticHotWaterActiveMode(),
                          'temp-2')
Esempio n. 6
0
 def test_getDomesticHotWaterCirculationMode_wed_10_10_time(self):
     with now_is('2021-09-08 10:10:00'):
         self.assertEqual(
             self.device.getDomesticHotWaterCirculationMode(), 'off')