-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_helper_functions.py
47 lines (32 loc) · 1.26 KB
/
test_helper_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from unittest import TestCase
from unittest.mock import patch
from helper_functions import add_five, add_five_to_random_int_less_than_ten
class TestHelperFunctions(TestCase):
def setUp(self):
self.num_to_pass = 2
def test_add_five_function_returns_expected_value_when_negative_integer_passed_in(self):
# Arrange
self.num_to_pass = -2
expected_value = 3
# Act
actual_value = add_five(self.num_to_pass)
# Assert
self.assertEqual(expected_value, actual_value)
def test_add_five_function_returns_expected_value(self):
# Arrange
expected_value = 7
# Act
actual_value = add_five(self.num_to_pass)
# Assert
self.assertEqual(expected_value, actual_value)
def test_add_five_function_raises_exception_when_non_int_value_passed(self):
self.num_to_pass = "test"
with self.assertRaises(TypeError):
add_five(self.num_to_pass)
@patch("helper_functions.get_random_number_less_than_ten")
def test_add_five_to_random_int_less_than_ten(self, mock_func):
mock_func.return_value = 10
actual_value = add_five_to_random_int_less_than_ten()
self.assertEqual(15, actual_value)
def tearDown(self):
pass