def test_gemeinsam_import_adde_passende_kategorie_should_import_value(): set_up() einzelbuchungen = database_instance().einzelbuchungen einzelbuchungen.add(datum('01.01.2017'), 'Essen', 'some name', -1.54) requester.INSTANCE = RequesterStub( { 'https://test.test/gemeinsamebuchung.php': _JSON_IMPORT_DATA_GEMEINSAM, 'https://test.test/deletegemeinsam.php': '', 'https://test.test/login.php': LOGIN_RESPONSE }, DECODED_LOGIN_DATA, auth_cookies=LOGIN_COOKIES) context = import_data.index( PostRequest({ 'action': 'load_online_gemeinsame_transactions', 'email': '', 'server': 'test.test', 'password': '' })) assert context['element_titel'] == 'Export / Import' assert len(database_instance().gemeinsamebuchungen.content) == 2 assert database_instance().gemeinsamebuchungen.get( 0)['Name'] == 'Testausgabe1' assert database_instance().gemeinsamebuchungen.get( 0)['Person'] == 'TestUser' assert database_instance().gemeinsamebuchungen.get( 1)['Name'] == 'Testausgabe2' assert requester.instance().call_count_of( 'https://test.test/deletegemeinsam.php') == 1 assert requester.instance().complete_call_count() == 3
def test_gemeinsam_import_with_unpassenden_kategorie_should_import_value_and_requestmapping( ): set_up() einzelbuchungen = database_instance().einzelbuchungen einzelbuchungen.add(datum('01.01.2017'), 'KeinEssen', 'some name', -1.54) requester.INSTANCE = RequesterStub( { 'https://test.test/gemeinsamebuchung.php': _JSON_IMPORT_DATA_GEMEINSAM, 'https://test.test/deletegemeinsam.php': '', 'https://test.test/login.php': LOGIN_RESPONSE }, DECODED_LOGIN_DATA, auth_cookies=LOGIN_COOKIES) context = import_data.index( PostRequest({ 'action': 'load_online_gemeinsame_transactions', 'email': '', 'server': 'test.test', 'password': '' })) assert context['element_titel'] == 'Kategorien zuweisen' assert context['import'] == _IMPORT_DATA_GEMEINSAM assert context['unpassende_kategorien'] == ['Essen'] context = import_data.index( PostRequest({ 'action': 'map_and_push', 'Essen_mapping': 'neue Kategorie anlegen', 'import': _IMPORT_DATA_GEMEINSAM })) assert context['element_titel'] == 'Export / Import' assert len(database_instance().gemeinsamebuchungen.content) == 2 assert database_instance( ).gemeinsamebuchungen.content.Person[0] == 'TestUser' assert database_instance( ).gemeinsamebuchungen.content.Person[1] == 'Partner' assert database_instance( ).gemeinsamebuchungen.content.Kategorie[0] == 'Essen' assert 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_gemeinsam_import_with_unpassenden_partnername_should_import_value_and_repalce_name( ): set_up() einzelbuchungen = database_instance().einzelbuchungen einzelbuchungen.add(datum('01.01.2017'), 'Essen', 'some name', -1.54) requester.INSTANCE = RequesterStub( { 'https://test.test/gemeinsamebuchung.php': _JSON_IMPORT_DATA_GEMEINSAM_WRONG_PARTNER, 'https://test.test/deletegemeinsam.php': '', 'https://test.test/login.php': LOGIN_RESPONSE }, DECODED_LOGIN_DATA, auth_cookies=LOGIN_COOKIES) context = import_data.index( PostRequest({ 'action': 'load_online_gemeinsame_transactions', 'email': '', 'server': 'test.test', 'password': '' })) assert context['element_titel'] == 'Export / Import' assert len(database_instance().gemeinsamebuchungen.content) == 2 assert database_instance().gemeinsamebuchungen.get(0) == { 'Datum': datetime.date(2019, 7, 11), 'Dynamisch': False, 'Kategorie': 'Essen', 'Name': 'Testausgabe2', 'Person': 'TestUser', 'Wert': -0.9, 'index': 0 } assert database_instance().gemeinsamebuchungen.get(1) == { 'Datum': datetime.date(2019, 7, 15), 'Dynamisch': False, 'Kategorie': 'Essen', 'Name': 'Testausgabe1', 'Person': 'Partner', 'Wert': -1.3, 'index': 1 } assert requester.instance().call_count_of( 'https://test.test/deletegemeinsam.php') == 1 assert requester.instance().complete_call_count() == 3
def test_einzelbuchung_import_adde_passende_kategorie_should_import_value(): set_up() einzelbuchungen = database_instance().einzelbuchungen einzelbuchungen.add(datum('01.01.2017'), 'Essen', 'some name', -1.54) requester.INSTANCE = RequesterStub( { 'https://test.test/einzelbuchung.php': _JSON_IMPORT_DATA, 'https://test.test/deleteitems.php': '', 'https://test.test/login.php': LOGIN_RESPONSE }, mocked_decode=DECODED_LOGIN_DATA) context = import_data.index( PostRequest({ 'action': 'load_online_transactions', 'email': '', 'server': 'test.test', 'password': '' })) assert context['element_titel'] == 'Export / Import' assert len(database_instance().einzelbuchungen.content) == 3 assert database_instance().einzelbuchungen.get(1) == { 'Datum': datum('11.07.2019'), 'Dynamisch': False, 'Kategorie': 'Essen', 'Name': 'Testausgabe2', 'Tags': np.nan, 'Wert': -0.9, 'index': 1 } assert database_instance().einzelbuchungen.get(2) == { 'Datum': datum('15.07.2019'), 'Dynamisch': False, 'Kategorie': 'Essen', 'Name': 'Testausgabe1', 'Tags': np.nan, 'Wert': -1.3, 'index': 2 } assert requester.instance().call_count_of( 'https://test.test/deleteitems.php') == 1 assert requester.instance().complete_call_count() == 3
def test_set_kategorien_with_ausgeschlossene_kategoerien_should_hide_ausgeschlossene_kategorien( ): set_up() database_instance().einzelbuchungen.add(datum('20.01.1990'), 'JaEins', 'SomeTitle', -10) database_instance().einzelbuchungen.add(datum('20.01.1990'), 'NeinEins', 'SomeTitle', -10) 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': '', 'https://test.test/login.php': LOGIN_RESPONSE }, DECODED_LOGIN_DATA, auth_cookies=LOGIN_COOKIES) result = import_data.index( PostRequest({ 'action': 'set_kategorien', 'email': '', 'server': 'test.test', 'password': '' })) assert result['message'] assert result['message_type'] == 'success' assert result[ 'message_content'] == 'Kategorien erfolgreich in die Online-Version übertragen.' assert requester.instance().data_of_request( 'https://test.test/setkategorien.php' )[0]['kategorien'] == 'JaEins,JaZwei'
def get_gemeinsame_buchungen(server_url, auth_container): json_data = requester.instance().post(GEMEINSAMEBUCHUNGEN_URL.format(server_url=server_url), cookies=auth_container.cookies()) return json.loads(json_data)
def delete_gemeinsame_buchungen(server_url, auth_container): requester.instance().post(DELETE_GEMEINSAMEBUCHUNGEN_URL.format(server_url=server_url), cookies=auth_container.cookies())
def upload_gemeinsame_buchungen(server_url, data, auth_container): json_data = requester.instance().put(GEMEINSAMEBUCHUNGEN_URL.format(server_url=server_url), data, auth_container.cookies()) return json.loads(json_data)['result'] == 'OK'
def get_partnername(server_url, auth_container): partner_configuration_string = requester.instance().post( PARTNER_URL.format(server_url=server_url), cookies=auth_container.cookies()) partner_configuration = json.loads(partner_configuration_string) return partner_configuration['partnername']
def login(server_url, email, password): auth_request = requester.instance().post_raw(LOGIN_URL.format(server_url=server_url), data={'email': email, 'password': password}) auth_container = json.loads(requester.instance().decode(auth_request)) return OnlineAuth(server_url, auth_container['username'], auth_request.cookies)
def get_data_for(isin): data = json.loads(requester.instance().get(URL.format(isin=isin))) print('loaded etf data:', data) return _map_data(data)
def set_kategorien(server_url, kategorien, auth_container): requester.instance().post(SET_KATEGORIEN_URL.format(server_url=server_url), data={'kategorien': kategorien}, cookies=auth_container.cookies())
def get_einzelbuchungen(server_url, auth_container): json_data = requester.instance().post( EINZELBUCHUNGEN_URL.format(server_url=server_url), cookies=auth_container.cookies()) return json.loads(json_data)
def delete_einzelbuchungen(server_url, auth_container): requester.instance().post(DELETEITEMS_URL.format(server_url=server_url), cookies=auth_container.cookies())