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)
示例#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)
示例#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())
示例#4
0
 def test_error_code_with_regular(self):
     faj = FroniusArchiveJson(archive_json)
     self.assertEqual(faj.error_code(), 0)
示例#5
0
 def test_error_code_with_error(self):
     faj = FroniusArchiveJson(error_json)
     self.assertEqual(faj.error_code(), 255)
示例#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())
示例#7
0
 def test_errorStatus_with_error(self):
     faj = FroniusArchiveJson(error_json)
     self.assertTrue(type(faj.error_status()), str)
示例#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())
示例#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())
示例#10
0
 def test_data_with_error(self):
     faj = FroniusArchiveJson(error_json)
     self.assertEqual(faj.data(), {})
示例#11
0
 def test_constructor_cannot_accept_empty_dict(self):
     with self.assertRaises(AssertionError):
         FroniusArchiveJson(dict())
示例#12
0
 def test_channels_with_regular(self):
     faj = FroniusArchiveJson(archive_json)
     self.assertNotEqual(0, len(faj.channels()))
示例#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())
示例#14
0
 def test_device_ids_with_error(self):
     faj = FroniusArchiveJson(error_json)
     self.assertEqual(0, len(faj.device_ids()))
示例#15
0
 def test_device_ids_with_regular(self):
     faj = FroniusArchiveJson(archive_json)
     self.assertNotEqual(0, len(faj.device_ids()))
示例#16
0
 def test_is_not_empty_with_not_empty(self):
     faj = FroniusArchiveJson(archive_json)
     self.assertTrue(self, faj.is_empty())
示例#17
0
 def test_constructor_can_accept_regular_response(self):
     FroniusArchiveJson(archive_json)
示例#18
0
 def test_constructor_can_accept_error_response(self):
     FroniusArchiveJson(error_json)
示例#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())
示例#20
0
 def test_constructor_cannot_accept_string(self):
     with self.assertRaises(AssertionError):
         FroniusArchiveJson("not a json object")