Skip to content

Commit db03143

Browse files
committed
Tests: get_mock_xyz
1 parent 21180f2 commit db03143

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

arc/job/adapters/mockter_test.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from arc.common import ARC_PATH, read_yaml_file
1313
from arc.job.adapters.mockter import MockAdapter
1414
from arc.level import Level
15+
from arc.reaction.reaction import ARCReaction
1516
from arc.settings.settings import input_filenames, output_filenames
1617
from arc.species import ARCSpecies
1718

@@ -47,6 +48,16 @@ def setUpClass(cls):
4748
species=[ARCSpecies(label='spc3', xyz=['O 0 0 1\nH 0 0 0\nH 1 0 0'], is_ts=True)],
4849
testing=True,
4950
)
51+
cls.job_4 = MockAdapter(job_type='tsg',
52+
level=Level(method='mock)', basis='cc-pVmockZ'),
53+
project='test',
54+
project_directory=os.path.join(ARC_PATH, 'arc', 'testing', 'test_MockAdapter_4'),
55+
reactions=[ARCReaction(r_species=[ARCSpecies(label='O', smiles='[O]'),
56+
ARCSpecies(label='CCC', smiles='CCC')],
57+
p_species=[ARCSpecies(label='OH', smiles='[OH]'),
58+
ARCSpecies(label='CCCyl', smiles='[CH2]CC')])],
59+
testing=True,
60+
)
5061

5162
def test_set_cpu_and_mem(self):
5263
"""Test assigning number of cpu's and memory"""
@@ -109,6 +120,31 @@ def test_write_input_file(self):
109120
'H 1.00000000 0.00000000 0.00000000'}
110121
self.assertEqual(content_3, job_3_expected_input_file)
111122

123+
def test_get_mock_xyz(self):
124+
"""Test getting the xyz coordinates from the mock input file"""
125+
self.job_1.write_input_file()
126+
xyz = self.job_1.get_mock_xyz()
127+
expected_xyz = ((0.0, 0.0, 1.0),)
128+
self.assertEqual(xyz['coords'], expected_xyz)
129+
130+
self.job_4.write_input_file()
131+
xyz = self.job_4.get_mock_xyz()
132+
expected_xyz = {'coords': ((0.0, 0.0, 0.0),
133+
(-1.23638885, -0.31576286, 0.08035856),
134+
(-0.01951084, 0.58603214, 0.20011967),
135+
(1.25111292, -0.12649245, -0.23138091),
136+
(-1.1299088, -1.20421894, 0.71100631),
137+
(-1.38117893, -0.64405306, -0.95389019),
138+
(-2.13745897, 0.21915243, 0.39632612),
139+
(-0.16491381, 1.47886657, -0.41803363),
140+
(0.08498971, 0.92174781, 1.23780143),
141+
(1.43621378, -1.00896698, 0.38941334),
142+
(1.1849428, -0.44879975, -1.27548267),
143+
(2.11210099, 0.5424951, -0.13623803)),
144+
'isotopes': (16, 12, 12, 12, 1, 1, 1, 1, 1, 1, 1, 1),
145+
'symbols': ('O', 'C', 'C', 'C', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H')}
146+
self.assertEqual(xyz, expected_xyz)
147+
112148
def test_executing_mockter(self):
113149
"""Test executing mockter"""
114150
self.job_1.execute()
@@ -118,7 +154,7 @@ def test_executing_mockter(self):
118154

119155
self.job_2.execute()
120156
output = read_yaml_file(os.path.join(self.job_2.local_path, output_filenames[self.job_2.job_adapter]))
121-
self.assertEqual(output['xyz'], 'O 0.00000000 0.00000000 1.00000000')
157+
self.assertEqual(output['xyz'], {'coords': ((0.0, 0.0, 1.0),), 'isotopes': (16,), 'symbols': ('O',)})
122158

123159
self.job_3.execute()
124160
output = read_yaml_file(os.path.join(self.job_3.local_path, output_filenames[self.job_3.job_adapter]))
@@ -131,7 +167,7 @@ def tearDownClass(cls):
131167
A function that is run ONCE after all unit tests in this class.
132168
Delete all project directories created during these unit tests
133169
"""
134-
for folder in ['test_MockAdapter_1', 'test_MockAdapter_2', 'test_MockAdapter_3']:
170+
for folder in ['test_MockAdapter_1', 'test_MockAdapter_2', 'test_MockAdapter_3', 'test_MockAdapter_4']:
135171
shutil.rmtree(os.path.join(ARC_PATH, 'arc', 'testing', folder), ignore_errors=True)
136172

137173

0 commit comments

Comments
 (0)