def test_ShowMeasurementsOfSensor(self):
     sensor = SensorDAO.readAllSensors(self._datastore.get_Database())[0]
     sensor.readMyMeasurements(self._datastore.get_Database())
     result = ""
     for m in sensor.getMeasurements():
         result += str(m) + "\n"
     self.assertResultByFile(result,"test_ShowMeasurementsOfSensor.txt")
 def test_showAllMeasurements(self):
     sensorlist = SensorDAO.readMeasurements(self._datastore.get_Database())
     result = ""
     for s in sensorlist:
         for m in s.getMeasurements():
             result += str(m) + "\n"
     self.assertResultByFile(result,"test_showAllMeasurements.txt")
 def get_samples(self,fromTimestamp=None,toTimestamp=None):
     """Anzahl von Messwerten eines Zeitraumes aus der Datenbank auslesen.
        Parameter:
        fromDatetime   -- Timestamp, Anfangszeitpunkt der Messwerte
        toDatetime     -- Timestamp, Endzeitpunkt der Messwerte
     """
     sensors = SensorDAO.readMeasurements(self._db,fromTimestamp=fromTimestamp,toTimestamp=toTimestamp)
     measurements = []
     for s in sensors:
         for m in s.getMeasurements():
             measurements.append(m)
     return measurements
 def test_ShowMeasurementsWithFilter(self):
     sensorlist = SensorDAO.readMeasurements(self._datastore.get_Database(), \
             topCount=1, \
             #sensorIDs=[1,3,4], \
             fromTimestamp=datetime.datetime.strptime("2013-01-01 00:00","%Y-%m-%d %H:%M"), \
             toTimestamp=datetime.datetime.strptime("2013-01-01 23:58","%Y-%m-%d %H:%M"), \
         )
     result = ""
     for s in sensorlist:
         for m in s.getMeasurements():
             result += str(m) + "\n"
     self.assertResultByFile(result,"test_ShowMeasurementsWithFilter.txt")
 def test_insertSampleMeasure(self):
     sensors = SensorDAO.readAllSensors(self._datastore.get_Database())
     measure = MeasurementDAO(sensors[0].getName(),datetime.datetime.now(),0.0,None)
     measure.insert(self._datastore.get_Database())
 def test_showSensors(self):
     sensorlist = SensorDAO.readAllSensors(self._datastore.get_Database())
     result = ""
     for s in sensorlist:
         result += s.getName() + "\n"
     self.assertResultByFile(result,"test_showSensors.txt")