Exemple #1
0
    def test_size():
        """Test that ``size`` is correct."""
        carb_3 = AtomSpec(6, 3)
        carb_1 = AtomSpec(6, 1)

        atoms = [carb_3, carb_1, carb_1, carb_3]
        bonds = [
            BondSpec(0, 1, BondOrder(1)),
            BondSpec(1, 2, BondOrder(2), True),
            BondSpec(2, 3, BondOrder(1)),
        ]

        molecule = Molecule(atoms, bonds)
        assert molecule.size() == 3
Exemple #2
0
    def test_given_bond_parity():
        """Test a given bond parity."""
        carb_3 = AtomSpec(6, 3)
        carb_1 = AtomSpec(6, 1)

        atoms = [carb_3, carb_1, carb_1, carb_3]
        bonds = [
            BondSpec(0, 1, BondOrder(1)),
            BondSpec(1, 2, BondOrder(2), True),
            BondSpec(2, 3, BondOrder(1)),
        ]

        molecule = Molecule(atoms, bonds)
        assert molecule.bond_parity(1, 2) == Parity(True)
Exemple #3
0
    def test_given_bond_parity():
        """Test a given bond parity."""
        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), True),
            BondSpec(3, 4, BondOrder(1)),
            BondSpec(3, 5, BondOrder(1))
        ]

        molecule = Molecule(atoms, bonds)
        assert molecule.bond_parity(0, 3) == Parity(True)
Exemple #4
0
    def test_bond_parity():
        """Test the bond parity."""
        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_parity(0, 3) is None
Exemple #5
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
Exemple #6
0
def test_quadruple_bond():
    """Test that quadruple bonds fail normally."""
    with pytest.raises(ValueError):
        BondSpec(0, 1, 4)
    with pytest.raises(ValueError):
        BondSpec(0, 1, BondOrder(4))
Exemple #7
0
def test_triple_bond():
    """Test that triple bonds are created normally."""
    bond = BondSpec(5, 7, 3)
    assert bond.order == BondOrder(3)
    bond = BondSpec(0, 1, BondOrder(3))
    assert bond.order.as_int() == 3
Exemple #8
0
def test_double_bond():
    """Test that double bonds are created normally."""
    bond = BondSpec(4, 8, 2)
    assert bond.order == BondOrder(2)
    bond = BondSpec(0, 1, BondOrder(2))
    assert bond.order.as_int() == 2