def test_getRealtimeData(self):
     fi = FroniusInverter(inverter_ip)
     json = fi.get_inverter_realtime_data()
     frt = FroniusRealTimeJson(json)
     rtd = frt.data()
     self.assertEqual(type(rtd), pandas.core.frame.DataFrame)
     self.assertEqual(len(rtd), 1)
 def test_FroniusInverter_RT_rename_timestamp(self):
     fi = FroniusInverter(inverter_ip)
     json = fi.get_inverter_realtime_data()
     frt = FroniusRealTimeJson(json)
     label = "foo"
     rtd = frt.data(label)
     self.assertEqual(type(rtd), pandas.core.frame.DataFrame)
     self.assertEqual(len(rtd), 1)
     self.assertTrue(label in list(rtd))
    def test_FroniusInverter_RT_test_append(self):
        fi = FroniusInverter(inverter_ip)
        json = fi.get_inverter_realtime_data()
        frt = FroniusRealTimeJson(json)
        rtd = frt.data()
        # get 2nd observation.  occasionally the inverter will return the same value.
        # iterate until a new observation is returned.  iterate at most 10 times

        rtd2 = rtd
        retry = 10
        while (rtd.iloc[0,:]['ts'] == rtd2.iloc[0,:]['ts']) and (0 < retry):
            json = fi.get_inverter_realtime_data()
            frt = FroniusRealTimeJson(json)
            rtd2 = frt.data('ts', append=rtd)
            retry -= 1

        self.assertEqual(type(rtd2), pandas.core.frame.DataFrame)
        self.assertEqual(len(rtd2), 2)
        self.assertEqual(len(list(set(rtd2['ts']))), 2)
Beispiel #4
0
 def test_error_code_with_error(self):
     faj = FroniusRealTimeJson(realtime_error_json)
     self.assertEqual(faj.error_code(), 255)
Beispiel #5
0
 def test_errorStatus_with_error(self):
     faj = FroniusRealTimeJson(realtime_error_json)
     self.assertTrue(type(faj.error_status()), str)
Beispiel #6
0
 def test_timestamp_with_error(self):
     faj = FroniusRealTimeJson(realtime_error_json)
     dt = dateutil.parser.parse('2017-10-28T15:45:32+02:00')
     self.assertEqual(dt, faj.timestamp())
Beispiel #7
0
 def test_is_not_empty_with_not_empty(self):
     faj = FroniusRealTimeJson(realtime_json)
     self.assertTrue(self, faj.is_empty())
Beispiel #8
0
 def test_constructor_can_accept_regular_realtime_response(self):
     FroniusRealTimeJson(realtime_json)
Beispiel #9
0
 def test_constructor_cannot_accept_Archive_Json(self):
     with self.assertRaises(AssertionError):
         FroniusRealTimeJson(archive_json)