• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

iplweb / bpp / 740231c0-9328-4d43-8cf8-cce29c833ecd

31 Aug 2025 11:09PM UTC coverage: 37.271% (-9.8%) from 47.085%
740231c0-9328-4d43-8cf8-cce29c833ecd

push

circleci

mpasternak
Fix circleci maybe

16449 of 44133 relevant lines covered (37.27%)

0.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/bpp/tests/test_fields.py
1
from decimal import Decimal
×
2

3
import pytest
×
4
from django.core.exceptions import ValidationError
×
5

6
from bpp.fields import CommaDecimalField
×
7

8

9
def test_fields_CommaDecimalField_accepts_decimal_with_period():
×
10
    """Test that field accepts decimal with period separator"""
11
    field = CommaDecimalField(max_digits=10, decimal_places=2)
×
12
    result = field.to_python("10.50")
×
13
    assert result == Decimal("10.50")
×
14

15

16
def test_fields_CommaDecimalField_accepts_decimal_with_comma():
×
17
    """Test that field accepts decimal with comma separator"""
18
    field = CommaDecimalField(max_digits=10, decimal_places=2)
×
19
    result = field.to_python("10,50")
×
20
    assert result == Decimal("10.50")
×
21

22

23
def test_fields_CommaDecimalField_period_and_comma_produce_same_result():
×
24
    """Test that period and comma separators produce identical results"""
25
    field = CommaDecimalField(max_digits=10, decimal_places=2)
×
26
    result_period = field.to_python("10.50")
×
27
    result_comma = field.to_python("10,50")
×
28
    assert result_period == result_comma
×
29

30

31
def test_fields_CommaDecimalField_accepts_integer_as_string():
×
32
    """Test that field accepts integer values as strings"""
33
    field = CommaDecimalField(max_digits=10, decimal_places=2)
×
34
    result = field.to_python("10")
×
35
    assert result == Decimal("10")
×
36

37

38
def test_fields_CommaDecimalField_accepts_decimal_object():
×
39
    """Test that field accepts Decimal objects directly"""
40
    field = CommaDecimalField(max_digits=10, decimal_places=2)
×
41
    decimal_value = Decimal("10.50")
×
42
    result = field.to_python(decimal_value)
×
43
    assert result == decimal_value
×
44

45

46
def test_fields_CommaDecimalField_accepts_float():
×
47
    """Test that field accepts float values"""
48
    field = CommaDecimalField(max_digits=10, decimal_places=2)
×
49
    result = field.to_python(10.50)
×
50
    assert result == Decimal("10.50")
×
51

52

53
def test_fields_CommaDecimalField_handles_none_value():
×
54
    """Test that field handles None values"""
55
    field = CommaDecimalField(max_digits=10, decimal_places=2)
×
56
    result = field.to_python(None)
×
57
    assert result is None
×
58

59

60
def test_fields_CommaDecimalField_handles_empty_string():
×
61
    """Test that field handles empty strings"""
62
    field = CommaDecimalField(max_digits=10, decimal_places=2)
×
63
    result = field.to_python("")
×
64
    assert result is None
×
65

66

67
def test_fields_CommaDecimalField_raises_validation_error_for_invalid_input():
×
68
    """Test that field raises ValidationError for invalid input"""
69
    field = CommaDecimalField(max_digits=10, decimal_places=2)
×
70
    with pytest.raises(ValidationError):
×
71
        field.to_python("invalid")
×
72

73

74
def test_fields_CommaDecimalField_raises_validation_error_for_multiple_separators():
×
75
    """Test that field raises ValidationError for multiple separators"""
76
    field = CommaDecimalField(max_digits=10, decimal_places=2)
×
77
    with pytest.raises(ValidationError):
×
78
        field.to_python("10.5,2")
×
79

80

81
def test_fields_CommaDecimalField_complex_decimal_with_comma():
×
82
    """Test complex decimal numbers with comma separator"""
83
    field = CommaDecimalField(max_digits=10, decimal_places=2)
×
84
    result = field.to_python("1234,56")
×
85
    assert result == Decimal("1234.56")
×
86

87

88
def test_fields_CommaDecimalField_complex_decimal_with_period():
×
89
    """Test complex decimal numbers with period separator"""
90
    field = CommaDecimalField(max_digits=10, decimal_places=2)
×
91
    result = field.to_python("1234.56")
×
92
    assert result == Decimal("1234.56")
×
93

94

95
def test_fields_CommaDecimalField_negative_decimal_with_comma():
×
96
    """Test negative decimal numbers with comma separator"""
97
    field = CommaDecimalField(max_digits=10, decimal_places=2)
×
98
    result = field.to_python("-10,50")
×
99
    assert result == Decimal("-10.50")
×
100

101

102
def test_fields_CommaDecimalField_negative_decimal_with_period():
×
103
    """Test negative decimal numbers with period separator"""
104
    field = CommaDecimalField(max_digits=10, decimal_places=2)
×
105
    result = field.to_python("-10.50")
×
106
    assert result == Decimal("-10.50")
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc