Esempio 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), ))
Esempio 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)
Esempio 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',))
Esempio 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),))
Esempio 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)
Esempio n. 6
0
def test_masking_kwarg():
    assert raises(ValueError, Molecule, ({
        'a1': 'H',
        'a2': 'O'
    }, {
        'b1': {
            'nodes': ('a1', 'a2')
        }
    }), {'node': 13})
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio n. 11
0
def test_raises_true():
    function = int
    args = ["hello"]
    exception_type = ValueError
    assert raises(exception_type, function, args)
Esempio n. 12
0
def test_no_requirements_error():
    registrator = register_reaction_mechanism([], True)
    assert raises(InvalidReactionError, registrator, ((lambda x, y: None),))
Esempio n. 13
0
def test_raises_false():
    function = int
    args = [3]
    exception_type = ValueError
    assert not raises(exception_type, function, args)
Esempio n. 14
0
 def test_no_options(self):
     function = react
     args = [None, None, True]
     exception_type = FailedReactionError
     assert raises(exception_type, function, args)
Esempio 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', ))
Esempio n. 16
0
def test_no_requirements_error():
    registrator = register_reaction_mechanism([], True)
    assert raises(InvalidReactionError, registrator, ((lambda x, y: None), ))
Esempio n. 17
0
 def test_no_options(self):
     function = react
     args = [None, None, True]
     exception_type = FailedReactionError
     assert raises(exception_type, function, args)
Esempio n. 18
0
def test_raises_error():
    function = int
    args = ["hello"]
    exception_type = UnboundLocalError
    assert raises(ValueError, raises, (exception_type, function, args))
Esempio n. 19
0
def test_masking_kwarg():
    assert raises(ValueError, Molecule, (
        {'a1': 'H', 'a2': 'O'},
        {'b1': {'nodes': ('a1', 'a2')}}),
        {'node': 13}
    )