# Path: pynubank/utils/parsing.py
# def parse_pix_transaction(transaction: dict) -> dict:
#     if transaction['__typename'] != 'GenericFeedEvent':
#         return transaction
# 
#     if transaction['title'] in PIX_TRANSACTION_MAP.keys():
#         transaction['__typename'] = PIX_TRANSACTION_MAP[transaction['title']]
#         transaction['amount'] = parse_float(transaction['detail'])
# 
#     return transaction
# 
# def parse_float(value: str):
#     return float(re.search(r'(?:\d*\.)*\d+,\d{1,2}', value).group().replace('.', '').replace(',', '.'))


import pytest
from pynubank.utils.parsing import parse_pix_transaction, parse_float


base_transaction = {
    "id": "12c77a49-21c2-427d-8662-beba354e8356",
    "__typename": "GenericFeedEvent",
    "title": "Transferência enviada",
    "detail": "Waldisney da Silva\nR$ 3.668,40",
    "postDate": "2021-03-24"
}


def test_should_do_nothing_with_transactions_that_arent_pix():
    transaction = base_transaction.copy()
    transaction['__typename'] = 'TransferInEvent'
    transaction['amount'] = 3429


# Path: pynubank/utils/parsing.py
# def parse_pix_transaction(transaction: dict) -> dict:
#     if transaction['__typename'] != 'GenericFeedEvent':
#         return transaction
# 
#     if transaction['title'] in PIX_TRANSACTION_MAP.keys():
#         transaction['__typename'] = PIX_TRANSACTION_MAP[transaction['title']]
#         transaction['amount'] = parse_float(transaction['detail'])
# 
#     return transaction
# 
# def parse_float(value: str):
#     return float(re.search(r'(?:\d*\.)*\d+,\d{1,2}', value).group().replace('.', '').replace(',', '.'))


# Path: tests/test_parsing.py
import pytest
from pynubank.utils.parsing import parse_pix_transaction, parse_float



base_transaction = {
    "id": "12c77a49-21c2-427d-8662-beba354e8356",
    "__typename": "GenericFeedEvent",
    "title": "Transferência enviada",
    "detail": "Waldisney da Silva\nR$ 3.668,40",
    "postDate": "2021-03-24"
}


def test_should_do_nothing_with_transactions_that_arent_pix():
    transaction = base_transaction.copy()
    transaction['__typename'] = 'TransferInEvent'
    transaction['amount'] = 3429


    parsed = parse_pix_transaction(transaction)