def test_deserialise_posting_and_format(snapshot) -> None: txn = Transaction( {}, datetime.date(2017, 12, 12), "*", "Test3", "asdfasd", frozenset(["tag"]), frozenset(["link"]), [ deserialise_posting({"account": "Assets", "amount": "10"}), deserialise_posting({"account": "Assets", "amount": "10 EUR @"}), ], ) snapshot(_format_entry(txn, 61))
def test_serialise_posting(pos, amount): pos = Posting('Assets:ETrade:Cash', *pos) json = { 'account': 'Assets:ETrade:Cash', 'amount': amount, } assert loads(dumps(serialise(pos))) == json assert deserialise_posting(json) == pos
def test_serialise_posting( amount_cost_price: Tuple[Amount, Optional[CostSpec], Amount], amount_string: str, ) -> None: pos = Posting("Assets", *amount_cost_price, None, None) json = {"account": "Assets", "amount": amount_string} assert loads(dumps(serialise(pos))) == json assert deserialise_posting(json) == pos
def test_deserialise_posting( amount_cost_price: Tuple[Amount, Optional[CostSpec], Amount], amount_string: str, ) -> None: """Roundtrip is not possible here due to total price or calculation.""" pos = Posting("Assets", *amount_cost_price, None, None) json = {"account": "Assets", "amount": amount_string} assert deserialise_posting(json) == pos
def test_serialise_posting(pos, amount): pos = Posting('Assets:ETrade:Cash', *pos) json = { 'account': 'Assets:ETrade:Cash', 'amount': amount, } assert loads(dumps(serialise(pos))) == json assert deserialise_posting(json) == pos
def test_serialise_posting(pos, amount): pos = Posting("Assets:ETrade:Cash", *pos) json = {"account": "Assets:ETrade:Cash", "amount": amount} assert loads(dumps(serialise(pos))) == json assert deserialise_posting(json) == pos
def test_deserialise_posting(amount_cost_price, amount_string): """Roundtrip is not possible here due to total price or calculation.""" pos = Posting("Assets", *amount_cost_price, None, None) json = {"account": "Assets", "amount": amount_string} assert deserialise_posting(json) == pos
def test_serialise_posting(amount_cost_price, amount_string): pos = Posting("Assets", *amount_cost_price, None, None) json = {"account": "Assets", "amount": amount_string} assert loads(dumps(serialise(pos))) == json assert deserialise_posting(json) == pos
def test_deserialise_posting(amount_cost_price, amount_string): """Cases where a roundtrip is not possible due to total price.""" pos = Posting("Assets", *amount_cost_price, None, None) json = {"account": "Assets", "amount": amount_string} assert deserialise_posting(json) == pos