def setUp(self) -> None:
        self.data_per_hour = 1
        self.keep_raw = 3
        self.keep_day = 48
        self.keep_month = 30
        self.keep_year = 12
        self.keep_years = 3

        self.plugin_type = 'plugin1'

        self.db_file = FileLikeMock()
        self.state_file = FileLikeMock()

        self.database: Database = Database.create_database(
            self.database_file_callback, self.data_per_hour, self.keep_raw,
            self.keep_day, self.keep_month, self.keep_year, self.keep_years)
        self.plugin_loader: PluginLoader = PluginLoader(
            {'ElectricMeterPlugins': {
                self.plugin_type: 'TestPlugin'
            }}, 'testplugins')

        self.state: State = State.get_state(self.state_file_callback,
                                            self.deserialize_electric_meter)

        self.logic = Logic(self.state, self.database, self.plugin_loader,
                           self.data_per_hour)
 def test_save_load_database(self):
     # Create database and save
     db = Database.create_database(self.file_like_object_callback, self.dph, 3, 48, 30, 12, 3)
     db.sync_file = True
     db.add_data_src('test')
     db.add_data_src('data1')
     self.database_file.clear()
     db.add_data(123, 'data1')
     # Load data
     self.database_file.seek(0)  # Set pointer to file start
     db = Database.load_database(self.file_like_object_callback)
     # Assert
     self.assertIn('data1', db.datasources.keys())
     self.assertIn('test', db.datasources.keys())
     self.assertEqual(self.dph, db.dph)
     self.assertEqual(3, db.keep_raw)
     self.assertEqual(48, db.keep_day)
     self.assertEqual(30, db.keep_month)
     self.assertEqual(12, db.keep_year)
     self.assertEqual(3, db.keep_years)
     self.assertIn(123, [items['value'] for items in db.get_raw()['data1']])
     self.assertNotEqual(0, len([timestamp for value, timestamp in db.get_raw()['data1']]))
     # TODO vllt. bessere/schönere Art and timestamp zu kommen
     self.assertEqual(type(datetime.now()), type([item['timestamp'] for item in db.get_raw()['data1']][0]))