Exemplo n.º 1
0
def run(part_id: int, rec_id: int, run_id: int, timestamp: int, eda: float,
        ibi: float, temp: float, acc_x: float, acc_y: float, acc_z: float,
        spotify_username: str):
    if timestamp < 0:
        Stream.start(part_id, rec_id, run_id, spotify_username)
    else:
        values = TimestampValues(timestamp=timestamp,
                                 eda=eda,
                                 ibi=ibi,
                                 temp=temp,
                                 acc_x=acc_x,
                                 acc_y=acc_y,
                                 acc_z=acc_z)
        ProcessValue.single_value(part_id, rec_id, run_id, values,
                                  spotify_username)
Exemplo n.º 2
0
    def test_historic_ibi(self) -> None:
        db_session = next(deps.get_db())

        values = ProcessValue.get_historic_ibi(db_session, self.value_current.timestamp, self.rec_id, 2)

        self.assertEqual(2, len(values))
        self.assertEqual(190, values[0].timestamp)
        self.assertEqual(7, values[0].value1)
        self.assertEqual(180, values[1].timestamp)
        self.assertEqual(10, values[1].value1)
Exemplo n.º 3
0
 def test_convert_to_data_for_time_no_historic(self) -> None:
     val = TimestampValues(timestamp=170, eda=1.1, ibi=2.2, temp=3.3, acc_x=4.4, acc_y=5.5,
                           acc_z=6.6)
     data_for_time = ProcessValue.convert_to_data_for_time(db_session=self.db_session, values=val,
                                                           rec_id=self.rec_id, run_id=1)
     self.assertEqual(val.timestamp, data_for_time.timestamp)
     self.assertEqual(0, len(data_for_time.edaValues))
     self.assertEqual(0, len(data_for_time.ibiValues))
     self.assertEqual(val.temp, data_for_time.tempValue)
     self.assertEqual(3, len(data_for_time.accValues))
     self.assertEqual({'x': 4.4, 'y': 5.5, 'z': 6.6}, data_for_time.accValues[2])
     self.assertEqual({'x': 0, 'y': 0, 'z': 0}, data_for_time.accValues[1])
     self.assertEqual({'x': 0, 'y': 0, 'z': 0}, data_for_time.accValues[0])
Exemplo n.º 4
0
    def test_convert_to_data_for_time(self) -> None:
        val = TimestampValues(timestamp=self.value_current.timestamp, eda=1.1, ibi=2.2, temp=3.3, acc_x=4.4,
                              acc_y=5.5,
                              acc_z=6.6)
        data_for_time = ProcessValue.convert_to_data_for_time(db_session=self.db_session, values=val,
                                                              rec_id=self.rec_id, run_id=1)
        self.assertEqual(val.timestamp, data_for_time.timestamp)

        self.assertEqual(3, len(data_for_time.edaValues))
        self.assertEqual(7.0, data_for_time.edaValues[2])
        self.assertEqual(10.0, data_for_time.edaValues[1])
        self.assertEqual(13.0, data_for_time.edaValues[0])

        self.assertEqual(3, len(data_for_time.ibiValues))
        self.assertEqual(7.0, data_for_time.ibiValues[2])
        self.assertEqual(10.0, data_for_time.ibiValues[1])
        self.assertEqual(13.0, data_for_time.ibiValues[0])

        self.assertEqual(val.temp, data_for_time.tempValue)

        self.assertEqual(3, len(data_for_time.accValues))
        self.assertEqual({'x': 4.4, 'y': 5.5, 'z': 6.6}, data_for_time.accValues[2])
        self.assertEqual({'x': 7, 'y': 8, 'z': 9}, data_for_time.accValues[1])
        self.assertEqual({'x': 10, 'y': 11, 'z': 12}, data_for_time.accValues[0])