def test_gemeinsamImport_withUnpassendenKategorie_shouldImportValueAndRequestmapping( self): self.set_up() einzelbuchungen = viewcore.database_instance().einzelbuchungen einzelbuchungen.add(datum('01.01.2017'), 'KeinEssen', 'some name', -1.54) requester.INSTANCE = RequesterStub({ 'https://test.test/getgemeinsam.php': self._IMPORT_DATA_GEMEINSAM, 'https://test.test/deletegemeinsam.php': '', 'https://test.test/getusername.php': 'Sebastian' }) context = import_data.index( PostRequest({ 'action': 'load_online_gemeinsame_transactions', 'email': '', 'server': 'test.test', 'password': '' })) assert context['element_titel'] == 'Kategorien zuweisen' assert context['import'] == self._IMPORT_DATA_GEMEINSAM assert context['unpassende_kategorien'] == ['Essen'] context = import_data.index( PostRequest({ 'action': 'map_and_push', 'Essen_mapping': 'neue Kategorie anlegen', 'import': self._IMPORT_DATA_GEMEINSAM })) assert context['element_titel'] == 'Export / Import' assert len( viewcore.database_instance().gemeinsamebuchungen.content) == 2 assert viewcore.database_instance( ).gemeinsamebuchungen.content.Person[0] == 'Sebastian' assert viewcore.database_instance( ).gemeinsamebuchungen.content.Person[1] == 'Maureen' assert viewcore.database_instance( ).gemeinsamebuchungen.content.Kategorie[0] == 'Essen' assert viewcore.database_instance( ).gemeinsamebuchungen.content.Kategorie[1] == 'Essen' assert requester.instance().call_count_of( 'https://test.test/deletegemeinsam.php') == 1 assert requester.instance().complete_call_count() == 3
def test_set_kategorien_with_ausgeschlossene_kategoerien_should_hide_ausgeschlossene_kategorien( self): self.set_up() viewcore.database_instance().einzelbuchungen.add( datum('20.01.1990'), 'JaEins', 'SomeTitle', -10) viewcore.database_instance().einzelbuchungen.add( datum('20.01.1990'), 'NeinEins', 'SomeTitle', -10) viewcore.database_instance().einzelbuchungen.add( datum('20.01.1990'), 'JaZwei', 'SomeTitle', -10) configuration.index( PostRequest({ 'action': 'set_ausgeschlossene_kategorien', 'ausgeschlossene_kategorien': 'NeinEins' })) requester.INSTANCE = RequesterStub( {'https://test.test/setkategorien.php': ''}) context = import_data.index( PostRequest({ 'action': 'set_kategorien', 'email': '', 'server': 'test.test', 'password': '' })) assert requester.instance().data_of_request( 'https://test.test/setkategorien.php' )[0]['kategorien'] == 'JaEins,JaZwei'
def test_gemeinsamImport_withUnpassendenUsername_shouldImportValueAndRepalceName( self): self.set_up() einzelbuchungen = viewcore.database_instance().einzelbuchungen einzelbuchungen.add(datum('01.01.2017'), 'Essen', 'some name', -1.54) requester.INSTANCE = RequesterStub({ 'https://test.test/getgemeinsam.php': self._IMPORT_DATA_GEMEINSAM_WRONG_SELF, 'https://test.test/deletegemeinsam.php': '', 'https://test.test/getusername.php': 'Sebastian_Online' }) context = import_data.index( PostRequest({ 'action': 'load_online_gemeinsame_transactions', 'email': '', 'server': 'test.test', 'password': '' })) assert context['element_titel'] == 'Export / Import' assert len( viewcore.database_instance().gemeinsamebuchungen.content) == 2 assert viewcore.database_instance( ).gemeinsamebuchungen.content.Person[0] == 'Sebastian' assert viewcore.database_instance( ).gemeinsamebuchungen.content.Person[1] == 'Maureen' assert requester.instance().call_count_of( 'https://test.test/deletegemeinsam.php') == 1 assert requester.instance().complete_call_count() == 3
def test_addeUnpassendenKategorie_shouldShowImportMappingPage(self): self.set_up() einzelbuchungen = viewcore.database_instance().einzelbuchungen einzelbuchungen.add(datum('01.01.2017'), 'unbekannt', 'some name', -1.54) context = import_data.index(PostRequest({'import': self._IMPORT_DATA})) assert context['element_titel'] == 'Kategorien zuweisen'
def test_addePassendeKategorie_shouldImportValue(self): self.set_up() einzelbuchungen = viewcore.database_instance().einzelbuchungen einzelbuchungen.add(datum('01.01.2017'), 'Essen', 'some name', -1.54) context = import_data.index(PostRequest({'import': self._IMPORT_DATA})) assert context['element_titel'] == 'Export / Import' assert einzelbuchungen.select().select_year(2017).sum() == -11.54
def test_import_shouldWriteIntoAbrechnungen(self): self.set_up() einzelbuchungen = viewcore.database_instance().einzelbuchungen einzelbuchungen.add(datum('01.01.2017'), 'Essen', 'some name', -1.54) context = import_data.index(PostRequest({'import': self._IMPORT_DATA})) written_abrechnung = None for key in FileSystem.instance()._fs_stub.keys(): if key.startswith('../Import'): written_abrechnung = FileSystem.instance()._fs_stub[key] assert written_abrechnung == self._IMPORT_DATA
def test_init_shouldReturnIndexPage(self): self.set_up() context = import_data.index(GetRequest()) print(context) assert context['element_titel'] == 'Export / Import'