Пример #1
0
def test_description_not_list_handling():
    mm = MRA_Module(testing=True)
    content = KQMLList.from_string(
        '(BUILD-MODEL :DESCRIPTION ('
        ':TYPE "Inhibition" '
        ':SUBJ (:NAME "SB-525334" '
        '       :DB--REFS (:+TYPE+ "ONT::GENE-PROTEIN" '
        '                  :+TEXT+ "SB525334"'
        '                  :+PUBCHEM+ "9967941")) '
        ':OBJ (:NAME "TGFBR1"'
        '      :DB--REFS (:+TYPE+ "ONT::GENE-PROTEIN" '
        '                 :+TEXT+ "TGFBR1" '
        '                 :+HGNC+ "11772" '
        '                 :+UP+ "P36897" '
        '                 :+NCIT+ "C51730")) '
        ':OBJ--ACTIVITY "activity" '
        ':BELIEF 1 '
        ':EVIDENCE ((:SOURCE--API "trips" '
        '            :SOURCE--HASH -1613118243458052451)) '
        ':ID "ce486f46-3670-42e6-8f0e-d5f510525352" '
        ':MATCHES--HASH "-32031145755534420"))''')
    try:
        reply = mm.respond_build_model(content)
    except InvalidModelDescriptionError:
        return
    assert False, "Model should have explicitly failed: " + reply.to_string()
Пример #2
0
def test_respond_model_undo_no_model_yet():
    mm = MRA_Module(testing=True)
    content = KQMLList.from_string('(MODEL-UNDO)')
    reply = mm.respond_model_undo(content)
    assert reply.gets('model-id') == 'NIL'
    action = reply.get('action')
    assert action.head() == 'remove_stmts', reply
    stmts = action.get('statements')
    assert not stmts
Пример #3
0
def test_respond_model_undo():
    mm = MRA_Module(testing=True)
    _, content = _get_build_model_request('HRAS activates RAF')
    reply = mm.respond_build_model(content)
    _, content = _get_expand_model_request('NRAS activates RAF', '1')
    expand_reply = mm.respond_expand_model(content)
    expand_stmts = expand_reply.gets('model-new')
    content = KQMLList.from_string('(MODEL-UNDO)')
    reply = mm.respond_model_undo(content)
    assert reply.gets('model-id') == '3'
    action = reply.get('action')
    assert action.head() == 'remove_stmts'
    stmts = action.get('statements')
    assert json.loads(stmts.string_value()) == json.loads(expand_stmts)
Пример #4
0
def test_respond_model_undo():
    mm = MRA_Module(testing=True)
    _, content = _get_build_model_request('HRAS activates RAF')
    reply = mm.respond_build_model(content)
    _, content = _get_expand_model_request('NRAS activates RAF', '1')
    expand_reply = mm.respond_expand_model(content)
    expand_stmts = mm.get_statement(expand_reply.get('model-new'))
    assert len(expand_stmts) == 1
    content = KQMLList.from_string('(MODEL-UNDO)')
    reply = mm.respond_model_undo(content)
    assert reply.gets('model-id') == '3'
    action = reply.get('action')
    assert action.head() == 'remove_stmts'
    stmts = mm.get_statement(action.get('statements'))
    assert len(stmts) == 1
    assert stmts[0].equals(expand_stmts[0])
Пример #5
0
def test_gets():
    kl = KQMLList.from_string(b'(:hello "")')
    hello = kl.gets('hello')
    assert(hello == '')
Пример #6
0
def test_from_string():
    s = b'(FAILURE :reason INVALID_DESCRIPTION)'
    kl = KQMLList.from_string(s)
    for obj in kl.data:
        assert(isinstance(obj, KQMLObject))
Пример #7
0
 def test_gets(self):
     kl = KQMLList.from_string('(:hello "")')
     hello = kl.gets('hello')
     self.assertEqual(hello, '')
Пример #8
0
 def test_from_string(self):
     s = '(FAILURE :reason INVALID_DESCRIPTION)'
     kl = KQMLList.from_string(s)
     for obj in kl.data:
         self.assertFalse(isinstance(obj, string_types))