Skip to content

Commit 43b6110

Browse files
committed
added gain/lose charge atom test
1 parent 5cd5c27 commit 43b6110

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

rmgpy/molecule/moleculeTest.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,34 @@ def test_apply_action_lose_radical(self):
366366
self.assertEqual(atom0.charge, atom.charge)
367367
self.assertEqual(atom0.label, atom.label)
368368

369+
def test_apply_action_gain_charge(self):
370+
"""
371+
Test the Atom.apply_action() method for a GAIN_CHARGE action.
372+
"""
373+
action = ['GAIN_CHARGE', '*1', 1]
374+
for element in element_list:
375+
atom0 = Atom(element=element, radical_electrons=1, charge=0, label='*1', lone_pairs=0)
376+
atom = atom0.copy()
377+
atom.apply_action(action)
378+
self.assertEqual(atom0.element, atom.element)
379+
self.assertEqual(atom0.radical_electrons, atom.radical_electrons + 1)
380+
self.assertEqual(atom0.charge, atom.charge - 1)
381+
self.assertEqual(atom0.label, atom.label)
382+
383+
def test_apply_action_lose_charge(self):
384+
"""
385+
Test the Atom.apply_action() method for a LOSE_CHARGE action.
386+
"""
387+
action = ['LOSE_CHARGE', '*1', 1]
388+
for element in element_list:
389+
atom0 = Atom(element=element, radical_electrons=1, charge=0, label='*1', lone_pairs=0)
390+
atom = atom0.copy()
391+
atom.apply_action(action)
392+
self.assertEqual(atom0.element, atom.element)
393+
self.assertEqual(atom0.radical_electrons, atom.radical_electrons - 1)
394+
self.assertEqual(atom0.charge, atom.charge + 1)
395+
self.assertEqual(atom0.label, atom.label)
396+
369397
def test_equivalent(self):
370398
"""
371399
Test the Atom.equivalent() method.

0 commit comments

Comments
 (0)