diff --git a/pytr/dl.py b/pytr/dl.py index 916e130..28faca3 100644 --- a/pytr/dl.py +++ b/pytr/dl.py @@ -166,7 +166,7 @@ def dl_doc(self, doc, titleText, subtitleText, subfolder=None): return else: filepath = filepath_with_doc_id - doc["local filepath"] = str(filepath) + doc["local_filepath"] = str(filepath) self.filepaths.append(filepath) if filepath.is_file() is False: diff --git a/tests/sample_buy.json b/tests/sample_buy.json new file mode 100644 index 0000000..3001157 --- /dev/null +++ b/tests/sample_buy.json @@ -0,0 +1,191 @@ +{ + "id": "12345678", + "timestamp": "2024-02-20T16:32:07.731+0000", + "title": "Euro Stoxx 50 EUR (Dist)", + "icon": "logos/IE00B4K6B022/v2", + "badge": null, + "subtitle": "Kauforder", + "amount": { + "currency": "EUR", + "value": -3002.8, + "fractionDigits": 2 + }, + "subAmount": null, + "status": "EXECUTED", + "action": { + "type": "timelineDetail", + "payload": "12345678" + }, + "eventType": "ORDER_EXECUTED", + "source": "timelineTransaction", + "details": { + "id": "12345678", + "sections": [ + { + "title": "Du hast 3.002,80 € investiert", + "data": { + "icon": "logos/IE00B4K6B022/v2", + "subtitleText": null, + "timestamp": "2024-02-20T16:32:07.731+0000", + "status": "executed" + }, + "action": { + "type": "instrumentDetail", + "payload": "IE00B4K6B022" + }, + "type": "header" + }, + { + "title": "Übersicht", + "data": [ + { + "title": "Status", + "detail": { + "text": "Ausgeführt", + "functionalStyle": "EXECUTED", + "type": "status" + }, + "style": "plain" + }, + { + "title": "Orderart", + "detail": { + "text": "Kauf", + "trend": null, + "action": null, + "type": "text" + }, + "style": "plain" + }, + { + "title": "Asset", + "detail": { + "text": "Euro Stoxx 50 EUR (Dist)", + "trend": null, + "action": null, + "type": "text" + }, + "style": "plain" + } + ], + "action": null, + "type": "table" + }, + { + "title": "Transaktion", + "data": [ + { + "title": "Anteile", + "detail": { + "text": "60", + "trend": null, + "action": null, + "type": "text" + }, + "style": "plain" + }, + { + "title": "Aktienkurs", + "detail": { + "text": "50,03 €", + "trend": null, + "action": null, + "type": "text" + }, + "style": "plain" + }, + { + "title": "Gebühr", + "detail": { + "text": "1,00 €", + "trend": null, + "action": null, + "type": "text" + }, + "style": "plain" + }, + { + "title": "Gesamt", + "detail": { + "text": "3.002,80 €", + "trend": null, + "action": null, + "type": "text" + }, + "style": "highlighted" + } + ], + "action": null, + "type": "table" + }, + { + "title": "Dokumente", + "data": [ + { + "title": "Abrechnung", + "detail": "20.02.2024", + "action": { + "type": "browserModal", + "payload": "" + }, + "id": "", + "postboxType": "SECURITIES_SETTLEMENT", + "local filepath": "20241021/Abrechnung/2024-02-20 Abrechnung - Euro Stoxx 50 EUR (Dist).pdf" + }, + { + "title": "Basisinformationsblatt", + "detail": "20.02.2024", + "action": { + "type": "browserModal", + "payload": "" + }, + "id": "62c2529e", + "postboxType": "INFO", + "local filepath": "20241021/Basisinformationsblatt/2024-02-20 Basisinformationsblatt - Euro Stoxx 50 EUR (Dist).pdf" + }, + { + "title": "Kosteninformation", + "detail": "20.02.2024", + "action": { + "type": "browserModal", + "payload": "" + }, + "id": "668b8e97", + "postboxType": "COSTS_INFO_BUY_V2", + "local filepath": "20241021/Kosteninformation/2024-02-20 Kosteninformation - Euro Stoxx 50 EUR (Dist).pdf" + } + ], + "action": null, + "type": "documents" + }, + { + "title": "Hilfe", + "data": [ + { + "title": "Report a issue", + "detail": { + "icon": "logos/timeline_communication/v2", + "action": { + "type": "customerSupportChat", + "payload": { + "contextParams": { + "chat_flow_key": "NHC_0029_wealth_buying_selling_past_trade_execution", + "timelineEventId": "", + "primId": "" + }, + "contextCategory": "NHC" + } + }, + "style": "highlighted", + "type": "listItemAvatarDefault" + }, + "style": "plain" + } + ], + "action": null, + "type": "table" + } + ] + }, + "has_docs": true + } \ No newline at end of file diff --git a/tests/test_event_csv_formatter.py b/tests/test_event_csv_formatter.py index 1f411aa..a7c9862 100644 --- a/tests/test_event_csv_formatter.py +++ b/tests/test_event_csv_formatter.py @@ -18,4 +18,23 @@ def test_event_csv_formatter(): csv_output = formatter.format(event) # Assert that the output is not an empty string - assert csv_output != "2024-09-10;Einlage;3.000;Vorname Nachname;;;;\n" + assert csv_output == "2024-09-10;Einlage;3.000;Vorname Nachname;;;;\n" + + + +def test_buy(): + # Load the sample JSON file + with open("tests/sample_buy.json", "r") as file: + sample_data = json.load(file) + + # Parse the JSON data using the from_dict function + event = Event.from_dict(sample_data) + + # Create an instance of EventCsvFormatter + formatter = EventCsvFormatter(lang="de") + + # Format the event to CSV + csv_output = formatter.format(event) + + # Assert that the output is not an empty string + assert csv_output == "2024-02-20;Kauf;-3.002,8;Euro Stoxx 50 EUR (Dist);IE00B4K6B022;60;-1;\n"