Skip to content

Commit 165b28f

Browse files
author
Pipeline
committed
t - Added tests around navigating directories for creating files.
1 parent af61179 commit 165b28f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/Infrastructure/EventLoggingManager/test_EventLoggingManager.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@ class TestsEventLoggingManager(unittest.TestCase):
99

1010
def test_log_file_should_be_created_if_doesnt_exist(self):
1111
file_utility = FileUtilities()
12-
file_utility.get_root_path = MagicMock(return_value='beginning of file path')
12+
beginning_of_file_path = 'beginning of file path'
13+
file_utility.get_root_path = MagicMock(return_value=beginning_of_file_path + "\\Infrastructure")
1314
file_utility.file_exists = MagicMock(return_value=False)
1415
file_utility.create_file = MagicMock(return_value=True)
1516

1617
EventLoggingManager(file_utility)
1718

18-
file_utility.create_file.assert_called_with(file_utility.get_root_path() + '\\MobTimerEvents.log')
19+
file_utility.create_file.assert_called_with(beginning_of_file_path + '\\MobTimerEvents.log')
1920

2021
def test_log_file_should_not_create_if_file_exists(self):
2122
file_utility = FileUtilities()
22-
file_utility.get_root_path = MagicMock(return_value='beginning of file path')
23+
file_utility.get_root_path = MagicMock(return_value='beginning of file path' + '\\Infrastructure')
2324
file_utility.file_exists = MagicMock(return_value=True)
2425
file_utility.create_file = MagicMock(return_value=True)
2526

@@ -29,7 +30,8 @@ def test_log_file_should_not_create_if_file_exists(self):
2930

3031
def test_log_file_should_append_to_log(self):
3132
file_utility = FileUtilities()
32-
file_utility.get_root_path = MagicMock(return_value='beginning of file path')
33+
beginning_of_file_path = 'beginning of file path'
34+
file_utility.get_root_path = MagicMock(return_value=beginning_of_file_path + '\\Infrastructure')
3335
file_utility.file_exists = MagicMock(return_value=True)
3436
file_utility.create_file = MagicMock(return_value=True)
3537
file_utility.append = MagicMock()
@@ -42,7 +44,7 @@ def test_log_file_should_append_to_log(self):
4244
calls = []
4345

4446
for entry in test_data:
45-
calls.append(call('beginning of file path\\MobTimerEvents.log', '\n'+entry))
47+
calls.append(call(beginning_of_file_path +'\\MobTimerEvents.log', '\n'+entry))
4648

4749
file_utility.append.assert_has_calls(calls)
4850

0 commit comments

Comments
 (0)