コード例 #1
0
def test_height_more200():
    parameter_count = 7
    parameters = ["postal_calc.py", "h4k2g2", "v9g8r7", "50", "50", "400", "4", "Xpress"]
    return_rate = postal_calc.main(parameter_count, parameters)
    assert return_rate == "Error: maximum height is 200cm."
コード例 #2
0
def test_invalid_height_format():
    parameter_count = 7
    parameters = ["postal_calc.py", "h4k2g2", "v9g8r7", "50", "50", "abc", "4", "Xpress"]
    return_rate = postal_calc.main(parameter_count, parameters)
    assert return_rate == "Error: not a valid numerical height (cm)."
コード例 #3
0
def test_height_less10():
    parameter_count = 7
    parameters = ["postal_calc.py", "h4k2g2", "v9g8r7", "50", "50", "0", "4", "Xpress"]
    return_rate = postal_calc.main(parameter_count, parameters)
    assert return_rate == "Error: height must be at least 10cm."
コード例 #4
0
def test_length_less10():
    parameter_count = 7
    parameters = ["postal_calc.py", "h4k2g2", "v9g8r7", "-5", "2", "3", "4", "Xpress"]
    return_rate = postal_calc.main(parameter_count, parameters)
    assert return_rate == "Error: length must be at least 10cm."
コード例 #5
0
def test_length_more200():
    parameter_count = 7
    parameters = ["postal_calc.py", "h4k2g2", "v9g8r7", "244", "2", "3", "4", "Xpress"]
    return_rate = postal_calc.main(parameter_count, parameters)
    assert return_rate == "Error: maximum length is 200cm."
コード例 #6
0
def test_invalid_destinationcode():
    parameter_count = 7
    parameters = ["postal_calc.py", "h4k2g2", "654321", "1", "2", "3", "4", "Xpress"]
    return_rate = postal_calc.main(parameter_count, parameters)
    assert return_rate == "Error: not a valid canadian destination postal code."
コード例 #7
0
def test_no_args():
    parameter_count = 0
    parameters = []
    return_rate = postal_calc.main(parameter_count, parameters)
    assert return_rate == "Usage: starting_code ending_code length width height weight post_type"
コード例 #8
0
def test_args_more7():
    parameter_count = 8
    parameters = ["postal_calc.py" "h4k2g2" "h3l1o0" "1" "2" "3" "4" "Xpress" "4"]
    return_rate = postal_calc.main(parameter_count, parameters)
    assert return_rate == "Usage: starting_code ending_code length width height weight post_type"
コード例 #9
0
def test_invalid_startcode():
    parameter_count = 7
    parameters = ["postal_calc.py", "123456", "654321", "1", "2", "3", "4", "Xpress"]
    return_rate = postal_calc.main(parameter_count, parameters)
    assert return_rate == "Error: not a valid canadian starting postal code."
コード例 #10
0
def test_total_post_rate_cost():
    parameter_count = 7
    parameters = ["postal_calc.py", "h4k2g2", "v9g8r7", "100", "100", "100", "1", "Xpress"]
    return_rate = postal_calc.main(parameter_count, parameters)
    assert return_rate == "15.50"
コード例 #11
0
def test_invalid_post_type():
    parameter_count = 7
    parameters = ["postal_calc.py", "h4k2g2", "v9g8r7", "100", "100", "100", "1", "hello"]
    return_rate = postal_calc.main(parameter_count, parameters)
    assert return_rate == "Error: not a valid post type (Regular, Xpress or Priority) case sensitive."
コード例 #12
0
def test_weight_more_maximum():
    parameter_count = 7
    parameters = ["postal_calc.py", "h4k2g2", "v9g8r7", "50", "50", "50", "31", "Xpress"]
    return_rate = postal_calc.main(parameter_count, parameters)
    assert return_rate == "Error: maximum weight is 30kg."
コード例 #13
0
def test_weight_less_minimum():
    parameter_count = 7
    parameters = ["postal_calc.py", "h4k2g2", "v9g8r7", "50", "50", "50", "0", "Xpress"]
    return_rate = postal_calc.main(parameter_count, parameters)
    assert return_rate == "Error: minimum weight is 0.1kg."
コード例 #14
0
def test_args_less7():
    parameter_count = 3
    parameters = ["postal_calc.py" "h4k2g2" "h1t3r3" "3"]
    return_rate = postal_calc.main(parameter_count, parameters)
    assert return_rate == "Usage: starting_code ending_code length width height weight post_type"