Skip to content

Commit 03713e8

Browse files
Incorporated code review comments, added more test cases
1 parent 525bc20 commit 03713e8

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

tests/test_trans_builder.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,69 @@ def test_with_line_method(mt_trans):
6464
assert trans.create_model['lines'][-1] == temp
6565

6666

67+
def test_with_line_method_with_string_line_number(mt_trans):
68+
"""Test method functionality of the Transaction Builder."""
69+
expected_resp_str_line_number = {
70+
'amount': 20,
71+
'number': 'shipping-1',
72+
'quantity': 100,
73+
'itemCode': 'ITEM2001',
74+
'taxCode': '1234567',
75+
'taxIncluded': False,
76+
'exemptionCode': '',
77+
}
78+
expected_resp_int_line_number = {
79+
'amount': 100,
80+
'number': '5',
81+
'quantity': 1,
82+
'itemCode': 'ITEM2005',
83+
'taxCode': '5555555',
84+
'taxIncluded': False,
85+
'exemptionCode': '',
86+
}
87+
trans = mt_trans.with_line(
88+
amount=20,
89+
quantity=100,
90+
item_code='ITEM2001',
91+
tax_code=1234567,
92+
tax_included=False,
93+
line_number='shipping-1',
94+
exemption_code="",
95+
).with_line(
96+
amount=100,
97+
quantity=1,
98+
item_code='ITEM2005',
99+
tax_code=5555555,
100+
tax_included=False,
101+
line_number=5,
102+
exemption_code="",
103+
)
104+
assert trans.create_model['lines'][0] == expected_resp_str_line_number
105+
assert trans.create_model['lines'][1] == expected_resp_int_line_number
106+
107+
108+
def test_with_line_method_with_optional_parameters(mt_trans):
109+
"""Test method functionality of the Transaction Builder."""
110+
expected_resp_int_line_number = {
111+
'amount': 100,
112+
'number': '5',
113+
'quantity': 1,
114+
'itemCode': 'ITEM2005',
115+
'taxCode': '',
116+
'taxIncluded': True,
117+
'exemptionCode': 'EXEMPT_CUST_002',
118+
}
119+
trans = mt_trans.with_line(
120+
amount=100,
121+
quantity=1,
122+
item_code='ITEM2005',
123+
tax_included=True,
124+
line_number=5,
125+
exemption_code="EXEMPT_CUST_002",
126+
)
127+
assert trans.create_model['lines'][0] == expected_resp_int_line_number
128+
129+
67130
def test_with_line_method_line_number_not_null(mt_trans):
68131
"""Test method functionality of the Transaction Builder."""
69132
temp = {
@@ -94,6 +157,26 @@ def test_with_exempt_line_method(mt_trans):
94157
assert trans.create_model['lines'][-1] == temp
95158

96159

160+
def test_with_exempt_line_method_quantity(mt_trans):
161+
"""Test method functionality of the Transaction Builder."""
162+
temp = {
163+
'amount': 100,
164+
'number': '1',
165+
'quantity': 5,
166+
'itemCode': 'ITEM2001',
167+
'exemptionCode': 'EXEMPT_THIS_CUSTOMER',
168+
'taxIncluded': False,
169+
'taxCode': '',
170+
}
171+
trans = mt_trans.with_exempt_line(
172+
quantity=5,
173+
amount=100,
174+
item_code='ITEM2001',
175+
exemption_code='EXEMPT_THIS_CUSTOMER',
176+
)
177+
assert trans.create_model['lines'][-1] == temp
178+
179+
97180
def test_with_diagnostics_method(mt_trans):
98181
"""Test method functionality of the Transaction Builder."""
99182
trans = mt_trans.with_diagnostics()

0 commit comments

Comments
 (0)