Esempio n. 1
0
    def test_confirm_assumption_Server_cannot_accept_any_TZ(self):
        """
            the server will return invalid date format (too much segments) '2017-10-31+20%3A00%3A00-08%3A00' error
            when sending datetimes in UTC+8
        """
        if skip_inverter_quirk_tests:
            self.skipTest('skipped test due to SKIP_INVERTER_QUIRK_TESTS')
        else:
            fi = FroniusInverter(inverter_ip)

            t1_utc_8 = datetime.datetime(year=2017, month=11, day=1, hour=4) - datetime.timedelta(hours=8)
            t1_utc_8 = pytz.timezone('Etc/GMT+8').localize(t1_utc_8, is_dst=None)

            data_1_day_J = fi.get_historical_data_json(t1_utc_8, t1_utc_8 + datetime.timedelta(hours=24), ["Current_AC_Phase_1"])

            faj = FroniusArchiveJson(data_1_day_J)
            self.assertEqual(faj.error_code(), 255)
Esempio n. 2
0
 def test_data_with_regular(self):
     faj = FroniusArchiveJson(archive_json)
     self.assertEqual(len(faj.data()), 2)
     self.assertEqual((faj.device_ids()),
                      ['datamanager:/dc/f0056cc6/', 'inverter/1'])
     self.assertEqual((faj.channels('datamanager:/dc/f0056cc6/')),
                      ['Digital_PowerManagementRelay_Out_1'])
     self.assertEqual((faj.channels('inverter/1')), ['TimeSpanInSec'])
     self.assertEqual(len(faj.data()['inverter/1']), 20)
Esempio n. 3
0
 def test_start_date_with_error(self):
     faj = FroniusArchiveJson(error_json)
     dt = dateutil.parser.parse('2017-10-01T00:00:00+02:00')
     self.assertEqual(dt, faj.start_date())
Esempio n. 4
0
 def test_error_code_with_regular(self):
     faj = FroniusArchiveJson(archive_json)
     self.assertEqual(faj.error_code(), 0)
Esempio n. 5
0
 def test_error_code_with_error(self):
     faj = FroniusArchiveJson(error_json)
     self.assertEqual(faj.error_code(), 255)
Esempio n. 6
0
 def test_timestamp_with_error(self):
     faj = FroniusArchiveJson(error_json)
     dt = dateutil.parser.parse('2017-10-24T10:29:59+02:00')
     self.assertEqual(dt, faj.timestamp())
Esempio n. 7
0
 def test_errorStatus_with_error(self):
     faj = FroniusArchiveJson(error_json)
     self.assertTrue(type(faj.error_status()), str)
Esempio n. 8
0
 def test_end_date_with_error(self):
     faj = FroniusArchiveJson(error_json)
     dt = dateutil.parser.parse('2017-10-29T23:59:59+01:00')
     self.assertEqual(dt, faj.end_date())
Esempio n. 9
0
 def test_timestamp_with_regular(self):
     faj = FroniusArchiveJson(archive_json)
     dt = dateutil.parser.parse('2017-10-25T09:17:20+02:00')
     self.assertEqual(dt, faj.timestamp())
Esempio n. 10
0
 def test_data_with_error(self):
     faj = FroniusArchiveJson(error_json)
     self.assertEqual(faj.data(), {})
Esempio n. 11
0
 def test_constructor_cannot_accept_empty_dict(self):
     with self.assertRaises(AssertionError):
         FroniusArchiveJson(dict())
Esempio n. 12
0
 def test_channels_with_regular(self):
     faj = FroniusArchiveJson(archive_json)
     self.assertNotEqual(0, len(faj.channels()))
Esempio n. 13
0
 def test_start_date_with_regular(self):
     faj = FroniusArchiveJson(archive_json)
     dt = dateutil.parser.parse('2017-10-25T00:00:00+02:00')
     self.assertEqual(dt, faj.start_date())
Esempio n. 14
0
 def test_device_ids_with_error(self):
     faj = FroniusArchiveJson(error_json)
     self.assertEqual(0, len(faj.device_ids()))
Esempio n. 15
0
 def test_device_ids_with_regular(self):
     faj = FroniusArchiveJson(archive_json)
     self.assertNotEqual(0, len(faj.device_ids()))
Esempio n. 16
0
 def test_is_not_empty_with_not_empty(self):
     faj = FroniusArchiveJson(archive_json)
     self.assertTrue(self, faj.is_empty())
Esempio n. 17
0
 def test_constructor_can_accept_regular_response(self):
     FroniusArchiveJson(archive_json)
Esempio n. 18
0
 def test_constructor_can_accept_error_response(self):
     FroniusArchiveJson(error_json)
Esempio n. 19
0
 def test_end_date_with_regular(self):
     faj = FroniusArchiveJson(archive_json)
     dt = dateutil.parser.parse('2017-10-25T23:59:59+02:00')
     self.assertEqual(dt, faj.end_date())
Esempio n. 20
0
 def test_constructor_cannot_accept_string(self):
     with self.assertRaises(AssertionError):
         FroniusArchiveJson("not a json object")