Ejemplo n.º 1
0
def test_not_callable_has_name():
    class _(object):
        __name__ = 'dumb'

    registrator = register_reaction_mechanism([_()], True)

    assert raises(InvalidReactionError, registrator, ((lambda x, y: None), ))
Ejemplo n.º 2
0
def test_add_existing_edge():
    a = Molecule({'a1': 'H', 'a2': 'O'}, {'b1': {'nodes': ('a1', 'a2')}})

    args = ['b1', {'nodes': ('a1', 'a2')}]
    function = a._add_edge
    exception_type = KeyError
    assert raises(exception_type, function, args)
Ejemplo n.º 3
0
def test_next_id_invalid():
    a = Molecule(
        {'a1': 'H', 'a2': 'O'},
        {'b1': {'nodes': ('a1', 'a2')}}
    )

    assert raises(ValueError, a._next_id, ('c',))
Ejemplo n.º 4
0
def test_not_callable_has_name():
    class _(object):
        __name__ = 'dumb'

    registrator = register_reaction_mechanism([_()], True)

    assert raises(InvalidReactionError, registrator, ((lambda x, y: None),))
Ejemplo n.º 5
0
def test_register_existing_reaction():
    function = register_reaction_mechanism([vacuous], True)

    def reaction2(*args):
        pass

    args = [reaction2]

    assert raises(ExistingReactionError, function, args)
Ejemplo n.º 6
0
def test_masking_kwarg():
    assert raises(ValueError, Molecule, ({
        'a1': 'H',
        'a2': 'O'
    }, {
        'b1': {
            'nodes': ('a1', 'a2')
        }
    }), {'node': 13})
Ejemplo n.º 7
0
def test_register_existing_reaction():
    function = register_reaction_mechanism([vacuous], True)

    def reaction2(*args):
        pass

    args = [reaction2]

    assert raises(ExistingReactionError, function, args)
Ejemplo n.º 8
0
def test_add_existing_edge():
    a = Molecule(
        {'a1': 'H', 'a2': 'O'},
        {'b1': {'nodes': ('a1', 'a2')}}
    )

    args = ['b1', {'nodes': ('a1', 'a2')}]
    function = a._add_edge
    exception_type = KeyError
    assert raises(exception_type, function, args)
Ejemplo n.º 9
0
def test_register_simple_reaction_with_invalid_requirements():
    voodoo = 17
    function = register_reaction_mechanism([voodoo], True)

    def reaction3(reactants, conditions):
        return 11

    args = [reaction3]

    assert raises(InvalidReactionError, function, args)
    assert not reaction_is_registered('reaction3', True)
    assert not reaction_is_registered(reaction3, True)
Ejemplo n.º 10
0
def test_register_simple_reaction_with_invalid_requirements():
    voodoo = 17
    function = register_reaction_mechanism([voodoo], True)

    def reaction3(reactants, conditions):
        return 11

    args = [reaction3]

    assert raises(InvalidReactionError, function, args)
    assert not reaction_is_registered('reaction3', True)
    assert not reaction_is_registered(reaction3, True)
Ejemplo n.º 11
0
def test_raises_true():
    function = int
    args = ["hello"]
    exception_type = ValueError
    assert raises(exception_type, function, args)
Ejemplo n.º 12
0
def test_no_requirements_error():
    registrator = register_reaction_mechanism([], True)
    assert raises(InvalidReactionError, registrator, ((lambda x, y: None),))
Ejemplo n.º 13
0
def test_raises_false():
    function = int
    args = [3]
    exception_type = ValueError
    assert not raises(exception_type, function, args)
Ejemplo n.º 14
0
 def test_no_options(self):
     function = react
     args = [None, None, True]
     exception_type = FailedReactionError
     assert raises(exception_type, function, args)
Ejemplo n.º 15
0
def test_next_id_invalid():
    a = Molecule({'a1': 'H', 'a2': 'O'}, {'b1': {'nodes': ('a1', 'a2')}})

    assert raises(ValueError, a._next_id, ('c', ))
Ejemplo n.º 16
0
def test_no_requirements_error():
    registrator = register_reaction_mechanism([], True)
    assert raises(InvalidReactionError, registrator, ((lambda x, y: None), ))
Ejemplo n.º 17
0
 def test_no_options(self):
     function = react
     args = [None, None, True]
     exception_type = FailedReactionError
     assert raises(exception_type, function, args)
Ejemplo n.º 18
0
def test_raises_error():
    function = int
    args = ["hello"]
    exception_type = UnboundLocalError
    assert raises(ValueError, raises, (exception_type, function, args))
Ejemplo n.º 19
0
def test_masking_kwarg():
    assert raises(ValueError, Molecule, (
        {'a1': 'H', 'a2': 'O'},
        {'b1': {'nodes': ('a1', 'a2')}}),
        {'node': 13}
    )