Example #1
0
#!/usr/bin/python3

from snippets import (lambda_array, read_file, calculate_unpaid_loans,
                      calculate_paid_loans, average_paid_loans, foo)

if __name__ == "__main__":
    try:
        lambdas = lambda_array()
        json_file = read_file()
        assert (lambdas[0](10) == 19), "lambdas[0](10) should equal 19"
        assert (len(
            json_file.get("loans")) == 15), "Number of loans should equal 15"
        assert (calculate_unpaid_loans(json_file) == 11062
                ), "Total unpaid loans should equal 11062"
        assert (calculate_paid_loans(json_file) == 29493.85304
                ), "Total paid loans should equal 29493.85304"
        assert (average_paid_loans(json_file) == 2681.2593672727276
                ), "Average of paid loans should equal 2681.2593672727276"
        assert (foo() == ["baz"]), "This should return a single item 'baz'"
        assert (
            foo() == ["baz"]
        ), "When I call the function the second time I should still get a single element in the array"
        print("All test passed successfully!! 😀")
    except (AssertionError, SyntaxError, TypeError) as error:
        print(error, " 😢")
Example #2
0
 def test_average_paid_loans(self):
     json_file = read_file()
     self.assertEqual(average_paid_loans(json_file), 2681.2593672727276)
Example #3
0
 def test_calculate_unpaid_loans(self):
     json_file = read_file()
     self.assertEqual(calculate_unpaid_loans(json_file), 11062)
Example #4
0
 def test_calculate_paid_loans(self):
     json_file = read_file()
     self.assertEqual(calculate_paid_loans(json_file), 29493.85304)
Example #5
0
 def test_number_of_loans_equals_15(self):
     json_file = read_file()
     self.assertEqual(len(json_file.get("loans")), 15)