コード例 #1
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_comparing_money_with_different_type_raises():
    with pytest.raises(UnsupportedOperatorType):
        Money(D('42'), 'EUR') > 21
    with pytest.raises(UnsupportedOperatorType):
        Money(D('42'), 'EUR') >= D('42')
    with pytest.raises(UnsupportedOperatorType):
        Money(D('42'), 'EUR') < 21
    with pytest.raises(UnsupportedOperatorType):
        Money(D('42'), 'EUR') <= 42
コード例 #2
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_money_init_with_changed_cent_factor():
    old_precision = Money.cent_factor
    Money.cent_factor = '.001'
    m = Money(D('10.00123231'), 'EUR')
    assert m.amount == D('10.001')
    assert m.currency == 'EUR'
    Money.cent_factor = old_precision
コード例 #3
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_comparing_money_with_different_currencies_raises():
    with pytest.raises(CurrencyMismatch):
        Money(D('42'), 'EUR') > Money(D('84'), 'USD')
    with pytest.raises(CurrencyMismatch):
        Money(D('42'), 'USD') >= Money(D('84'), 'EUR')
    with pytest.raises(CurrencyMismatch):
        Money(D('42'), 'USD') < Money(D('21'), 'EUR')
    with pytest.raises(CurrencyMismatch):
        Money(D('42'), 'USD') <= Money(D('21'), 'EUR')
コード例 #4
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_division_by_zero_raises_exception():
    with pytest.raises(ZeroDivisionError):
        Money(D('42'), 'EUR') / Money(D('0'), 'EUR')
コード例 #5
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_division_by_one_returns_money():
    assert Money(D('42'), 'EUR') == Money(D('42'), 'EUR') / D('1')
コード例 #6
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_money_not_equal_operator_with_other_objects():
    m1 = Money(D('42'), 'EUR')
    assert m1 != 42
    assert m1 != D('42')
    assert m1 != (D('42'), 'EUR')
コード例 #7
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_money_init_decimal_amount():
    m = Money(D('10'), 'EUR')
    assert m.amount == D('10')
    assert m.currency == 'EUR'
コード例 #8
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_money_init_invalid_amount():
    with pytest.raises(InvalidAmount):
        _ = Money('9,231', 'EUR')
コード例 #9
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_addition_of_money_with_different_currencie_raises():
    m1 = Money(D('21'), 'EUR')
    m2 = Money(D('21'), 'USD')
    with pytest.raises(CurrencyMismatch):
        m1 + m2
コード例 #10
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_multiplication_of_money_with_money_raises():
    with pytest.raises(UnsupportedOperatorType):
        Money(D('21'), 'EUR') * Money(D('2'), 'EUR')
コード例 #11
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_money_init_integer_amount():
    m = Money(10, 'EUR')
    assert m.amount == D('10')
    assert m.currency == 'EUR'
コード例 #12
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_subtraction_of_money_with_different_currencies_raises():
    with pytest.raises(CurrencyMismatch):
        Money(D('42'), 'EUR') - Money(D('42'), 'USD')
コード例 #13
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_subtraction_of_money_with_other_types_raises():
    with pytest.raises(UnsupportedOperatorType):
        Money(D('42'), 'EUR') - D('42')
コード例 #14
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_subtraction_of_money():
    assert Money(D('21'), 'EUR') == (
            Money(D('42'), 'EUR') - Money(D('21'), 'EUR'))
コード例 #15
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_using_sum_on_money():
    m1 = Money(D('21'), 'EUR')
    m2 = Money(D('21'), 'EUR')
    assert Money(D('42'), 'EUR') == sum([m1, m2])
コード例 #16
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_addition_of_money_with_other_types_raises():
    with pytest.raises(UnsupportedOperatorType):
        Money(D('21'), 'EUR') + D('21')
コード例 #17
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_division_by_decimal_returns_money():
    assert Money(D('8.4'), 'EUR') == Money(D('42'), 'EUR') / D('5')
コード例 #18
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_multiplication_of_money_with_decimal():
    assert Money(D('42'), 'EUR') == Money(D('21'), 'EUR') * D('2')
    assert Money(D('42'), 'EUR') == D('2') * Money(D('21'), 'EUR')
コード例 #19
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_division_with_different_currency_raises():
    with pytest.raises(CurrencyMismatch):
        Money(D('42'), 'EUR') / Money(D('21'), 'USD')
コード例 #20
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_money_init_rounds_amount_to_cent_factor():
    m = Money(D('10.00123231'), 'EUR')
    assert m.amount == D('10.00')
    assert m.currency == 'EUR'
コード例 #21
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_money_init_float_amount():
    m = Money(10.0, 'EUR')
    assert m.amount == D('10')
    assert m.currency == 'EUR'
コード例 #22
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_money_equal_operator():
    m1 = Money(D('42'), 'EUR')
    m2 = Money(D('42'), 'EUR')
    assert m1 == m2
コード例 #23
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_multiplication_with_non_decimal_raises():
    with pytest.raises(UnsupportedOperatorType):
        Money(D('21'), 'EUR') * 2
コード例 #24
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_addition_of_money():
    m1 = Money(D('21'), 'EUR')
    m2 = Money(D('21'), 'EUR')
    expected = Money(D('42'), 'EUR')
    assert m1 + m2 == expected
コード例 #25
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_money_repr():
    m = Money(D('42'), 'EUR')
    assert "Money(amount=Decimal('42.00'), currency='EUR')" == repr(m)
コード例 #26
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_division_of_money_with_money():
    assert D('2') == Money(D('42'), 'EUR') / Money(D('21'), 'EUR')
コード例 #27
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_money_equal_operator_with_different_currencies():
    m1 = Money(D('42'), 'EUR')
    m2 = Money(D('42'), 'USD')
    assert not m1 == m2
コード例 #28
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_money_init_string_amount():
    m = Money('10', 'EUR')
    assert m.amount == D('10')
    assert m.currency == 'EUR'
コード例 #29
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_money_not_equal_operator_with_different_amount():
    m1 = Money(D('42'), 'EUR')
    m2 = Money(D('21'), 'EUR')
    assert m1 != m2
コード例 #30
0
ファイル: test_pymoney.py プロジェクト: hrother/pymoney
def test_devision_of_money_with_money_fraction():
    assert D('8.4') == Money(D('42'), 'EUR') / Money(D('5'), 'EUR')