Skip to content

Commit

Permalink
improve pathfinderTest with more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bjkreitz committed Dec 13, 2024
1 parent 0738594 commit 6b405ee
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions test/rmgpy/molecule/pathfinderTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ class FindAdsorbateDelocalizationPathsTest:
test the find_adsorbate_delocalization_paths method
"""

def test_cch(self):
def test_xcxch(self):
adjlist = """
1 X u0 p0 c0 {3,D}
2 X u0 p0 c0 {4,S}
Expand All @@ -549,14 +549,33 @@ def test_cch(self):

mol = Molecule().from_adjacency_list(adjlist)
paths = find_adsorbate_delocalization_paths(mol.atoms[0])
no_surface_sites = sum(atom.is_surface_site() for atom in paths[0][:4])
assert paths
assert no_surface_sites == 2

def test_xcxch2(self):
adjlist = """
1 C u0 p0 c0 {2,S} {3,S} {4,S} {5,S}
2 C u0 p0 c0 {1,S} {6,T}
3 H u0 p0 c0 {1,S}
4 H u0 p0 c0 {1,S}
5 X u0 p0 c0 {1,S}
6 X u0 p0 c0 {2,T}
"""

mol = Molecule().from_adjacency_list(adjlist)
paths = find_adsorbate_delocalization_paths(mol.atoms[0])
assert len(paths) == 0




class FindAdsorbateConjugateDelocalizationPathsTest:
"""
test the find_adsorbate_conjugate_delocalization_paths
"""

def test_chchc(self):
def test_xchchxc(self):
adjlist = """
1 X u0 p0 c0 {3,T}
2 X u0 p0 c0 {5,S}
Expand All @@ -569,4 +588,24 @@ def test_chchc(self):

mol = Molecule().from_adjacency_list(adjlist)
paths = find_adsorbate_conjugate_delocalization_paths(mol.atoms[0])
assert paths
no_surface_sites = sum(atom.is_surface_site() for atom in paths[0][:5])
assert paths
assert no_surface_sites == 2

def test_xchch2xch2(self):
adjlist = """
1 C u0 p0 c0 {2,S} {3,S} {4,S} {5,S}
2 C u0 p0 c0 {1,S} {6,S} {7,S} {9,S}
3 C u0 p0 c0 {1,S} {8,S} {10,D}
4 H u0 p0 c0 {1,S}
5 H u0 p0 c0 {1,S}
6 H u0 p0 c0 {2,S}
7 H u0 p0 c0 {2,S}
8 H u0 p0 c0 {3,S}
9 X u0 p0 c0 {2,S}
10 X u0 p0 c0 {3,D}
"""

mol = Molecule().from_adjacency_list(adjlist)
paths = find_adsorbate_conjugate_delocalization_paths(mol.atoms[0])
assert len(paths) == 0

0 comments on commit 6b405ee

Please sign in to comment.