diff --git a/gmso/core/topology.py b/gmso/core/topology.py index 8e09cc929..b0fbd2ca6 100644 --- a/gmso/core/topology.py +++ b/gmso/core/topology.py @@ -1433,6 +1433,12 @@ def iter_connections_by_site(self, site, connections=None): connections = ["bonds", "angles", "dihedrals", "impropers"] else: connections = set([option.lower() for option in connections]) + for option in connections: + if option not in ["bonds", "angles", "dihedrals", "impropers"]: + raise ValueError( + "Valid connection types are limited to: " + '"bonds", "angles", "dihedrals", "impropers"' + ) for conn_str in connections: for conn in getattr(self, conn_str): if site in conn.connection_members: diff --git a/gmso/tests/test_topology.py b/gmso/tests/test_topology.py index f2198c675..dcb790d45 100644 --- a/gmso/tests/test_topology.py +++ b/gmso/tests/test_topology.py @@ -951,6 +951,15 @@ def test_iter_connections_by_site_none(self, ethane): ): assert site in conn.connection_members + def test_iter_connections_by_site_bad_param(self, ethane): + ethane.identify_connections() + site = ethane.sites[0] + with pytest.raises(ValueError): + for conn in ethane.iter_connections_by_site( + site=site, connections=["bond"] + ): + pass + def test_write_forcefield(self, typed_water_system): forcefield = typed_water_system.get_forcefield() assert "opls_111" in forcefield.atom_types