def teste_write_with_old_database_should_migrate(self):
        self.mock_filesystem()
        self.write_db_file_stub('testuser', self.full_db_old)

        database = database_manager.read('testuser', set())
        database_manager.write(database)

        assert file_system.instance().read(
            '../Database_testuser.csv') == file_system.instance(
            ).stub_pad_content(self.full_db)
Example #2
0
def database_instance():
    '''
    returns the actual database instance
    '''
    if not persisted_state.DATABASES:
        persisted_state.DATABASES = configuration_provider.get_configuration(
            'DATABASES').split(',')

    if persisted_state.DATABASE_INSTANCE is None:
        ausgeschlossene_kategorien = set(
            configuration_provider.get_configuration(
                'AUSGESCHLOSSENE_KATEGORIEN').split(','))
        persisted_state.DATABASE_INSTANCE = database_manager.read(
            persisted_state.DATABASES[0],
            ausgeschlossene_kategorien=ausgeschlossene_kategorien)
    return persisted_state.DATABASE_INSTANCE
    def teste_read_with_full_database(self):
        self.mock_filesystem()
        self.write_db_file_stub('testuser', self.full_db)

        database = database_manager.read('testuser', set())

        assert database.name == 'testuser'
        assert len(database.einzelbuchungen.content) == 25
        assert len(database.einzelbuchungen.content[
            database.einzelbuchungen.content.Dynamisch == False]) == 2
        assert database.einzelbuchungen.select().sum() == -675

        assert len(database.dauerauftraege.content) == 2
        assert database.dauerauftraege.content.Kategorie.tolist() == [
            'Essen', 'Miete'
        ]

        assert len(database.depotwerte.content) == 1
        assert len(database.order.content) == 3
        assert len(database.depotauszuege.content) == 1
        assert len(database.orderdauerauftrag.content) == 1
Example #4
0
def switch_database_instance(database_name):
    ausgeschlossene_kategorien = set(
        configuration_provider.get_configuration(
            'AUSGESCHLOSSENE_KATEGORIEN').split(','))
    persisted_state.DATABASE_INSTANCE = database_manager.read(
        database_name, ausgeschlossene_kategorien=ausgeschlossene_kategorien)