|
1 | 1 | import pytest
|
| 2 | +from moneyed import format_money |
2 | 3 |
|
| 4 | +from banker.common.locale import get_numeric_locale |
3 | 5 | from banker.formatter.html_transactions_formatter import HtmlTransactionsFormatter
|
4 | 6 |
|
5 | 7 |
|
@@ -31,9 +33,8 @@ def test_given_empty_transactions_when_format_transactions_then_return_empty_tab
|
31 | 33 |
|
32 | 34 | def test_given_transactions_when_format_transactions_then_return_html_table_with_headers_and_rows(
|
33 | 35 | html_transactions_formatter_sut, transaction1, transaction2):
|
34 |
| - html_hard_space = "\xa0" |
35 |
| - expected_transaction_1_value = f"-37,35{html_hard_space}zł" |
36 |
| - expected_transaction_2_value = f"-200,00{html_hard_space}zł" |
| 36 | + expected_transaction_1_value = format_money(transaction1.value, locale=get_numeric_locale()) |
| 37 | + expected_transaction_2_value = format_money(transaction2.value, locale=get_numeric_locale()) |
37 | 38 | expected_result = ('<table border="1" class="dataframe">\n'
|
38 | 39 | ' <thead>\n'
|
39 | 40 | ' <tr style="text-align: right;">\n'
|
@@ -65,3 +66,8 @@ def test_given_transactions_when_format_transactions_then_return_html_table_with
|
65 | 66 | actual_result = html_transactions_formatter_sut.format_transactions([transaction1, transaction2])
|
66 | 67 |
|
67 | 68 | assert actual_result == expected_result
|
| 69 | + # exact format is dependent on locale; try to make tests locale-independent |
| 70 | + assert "37" in expected_transaction_1_value |
| 71 | + assert "-" in expected_transaction_1_value |
| 72 | + assert "200" in expected_transaction_2_value |
| 73 | + assert "-" in expected_transaction_2_value |
0 commit comments