Skip to content

Commit 3e40cfc

Browse files
author
Pipeline
committed
r - Removed comments, refactored names
1 parent 5df00c2 commit 3e40cfc

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

Infrastructure/EventLoggingManager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
class EventLoggingManager:
55

66
def __init__(self, file_utility):
7-
file_path = file_utility.get_root_path() + "\\filename.txt"
7+
file_path = file_utility.get_root_path() + "\\MobTimerEvents.log"
88
if not file_utility.file_exists(file_path):
99
file_utility.create_file(file_path)

Infrastructure/FileUtilities.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,18 @@
77
class FileUtilities(object):
88
@staticmethod
99
def main_is_frozen():
10-
return (hasattr(sys, "frozen") or # new py2exe
11-
hasattr(sys, "importers") # old py2exe
12-
or imp.is_frozen("__main__")) # tools/freeze
10+
return (hasattr(sys, "frozen") or # new py2exe
11+
hasattr(sys, "importers") # old py2exe
12+
or imp.is_frozen("__main__")) # tools/freeze
1313

1414
def get_root_path(self):
1515
if FileUtilities.main_is_frozen():
1616
return os.path.dirname(sys.executable)
1717
return os.path.dirname(os.path.realpath(__file__))
1818

19-
def file_exists(self, path):
20-
return exists(path)
19+
def file_exists(self, file_path):
20+
return exists(file_path)
2121

22-
def create_file(self, filePath):
23-
f = open(filePath, "w")
24-
# f.write("Woops! I have deleted the content!")
22+
def create_file(self, file_path):
23+
f = open(file_path, "w")
2524
f.close()
26-
27-
# def __init__(self, file_utility):
28-
#
29-
# if not file_utility.file_exists():
30-
# file_utility.create_file("path to file")

tests/Infrastructure/EventLoggingManager/test_EventLoggingManager.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,17 @@
55
from Infrastructure.FileUtilities import FileUtilities
66

77

8-
# 1. Mock remaining File Utilities function calls
9-
# 2. Choose a real name for the log file
10-
118
class TestsEventLoggingManager(unittest.TestCase):
129

1310
def test_log_file_should_be_created_if_doesnt_exist(self):
14-
# Options: Mocks, Fake Files
15-
16-
# Arrange: Make sure the file does not exist
1711
file_utility = FileUtilities()
1812
file_utility.get_root_path = MagicMock(return_value='beginning of file path')
1913
file_utility.file_exists = MagicMock(return_value=False)
2014
file_utility.create_file = MagicMock(return_value=True)
21-
# Act: Instantiate EventLoggingManager
22-
event_logging_manager = EventLoggingManager(file_utility)
2315

24-
# Assert: Verify the file exists
25-
file_utility.create_file.assert_called_with(file_utility.get_root_path() + "\\filename.txt")
16+
EventLoggingManager(file_utility)
17+
18+
file_utility.create_file.assert_called_with(file_utility.get_root_path() + '\\MobTimerEvents.log')
2619

2720

2821
if __name__ == '__main__':

0 commit comments

Comments
 (0)