Skip to content

Commit 9ae4fc1

Browse files
Add test for setup config directory
1 parent 6662ade commit 9ae4fc1

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
# properties that suit your particular installation.
21
caching.inputs=
32
caching.ipfolder=

tests/unit/analysis/test_handle_config.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,22 @@ def test_get_script_name(self):
9696
self.assertEqual(handle_config.get_script_name(), "inputs")
9797

9898

99-
def test_setup_default_inputs(self):
100-
tempdir = tempfile.gettempdir()
101-
mock_path = os.path.join(tempdir, 'mock_inputs.py')
102-
# Make sure file does not exist from previous tests
103-
try:
104-
os.remove(mock_path)
105-
except FileNotFoundError:
106-
pass
99+
def test_setup_config_dir(self):
100+
tempdir = tempfile.TemporaryDirectory()
101+
handle_config.setup_config_dir(tempdir.name)
102+
103+
vesuvio_file = open(os.path.join(tempdir.name, "vesuvio.user.properties"), "r")
104+
self.assertEqual(vesuvio_file.read(), "caching.inputs=\ncaching.ipfolder=\n")
105+
vesuvio_file.close()
106+
mantid_file = open(os.path.join(tempdir.name, "Mantid.user.properties"), "r")
107+
self.assertEqual(mantid_file.read(), "default.facility=ISIS\ndefault.instrument=Vesuvio\ndatasearch.searcharchive=On\n")
108+
mantid_file.close()
109+
tempdir.cleanup()
110+
107111

112+
def test_setup_default_inputs(self):
113+
tempdir = tempfile.TemporaryDirectory()
114+
mock_path = os.path.join(tempdir.name, 'mock_inputs.py')
108115
with patch.object(handle_config, "VESUVIO_INPUTS_PATH", mock_path):
109116

110117
handle_config.setup_default_inputs()
@@ -125,4 +132,5 @@ def test_setup_default_inputs(self):
125132
file = open(mock_path, 'r')
126133
self.assertEqual(original_content, file.read())
127134
file.close()
128-
os.remove(mock_path)
135+
tempdir.cleanup()
136+

0 commit comments

Comments
 (0)