Esempio n. 1
0
    def test_bond_order_given_invalid():
        """
        Test that invalid bonds raise error when calling bond_order.

        """
        carb_3 = AtomSpec(6, 3)
        bond = BondSpec(0, 1, 1)
        molecule = Molecule([carb_3, carb_3], [bond])
        with pytest.raises(ValueError):
            molecule.bond_order(1, 2)
        with pytest.raises(ValueError):
            molecule.bond_order(2, 0)
Esempio n. 2
0
    def test_bond_order():
        """Test the bond orders."""
        carb = AtomSpec(6)
        hyd = AtomSpec(1)

        atoms = [carb, hyd, hyd, carb, hyd, hyd]
        bonds = [
            BondSpec(0, 1, BondOrder(1)),
            BondSpec(0, 2, BondOrder(1)),
            BondSpec(0, 3, BondOrder(2)),
            BondSpec(3, 4, BondOrder(1)),
            BondSpec(3, 5, BondOrder(1))
        ]

        molecule = Molecule(atoms, bonds)
        assert molecule.bond_order(0, 3).as_int() == 2