import os
from indra.sources import rlimsp

def test_simple_usage():
    rp = rlimsp.process_from_webservice('PMC3717945')
    stmts = rp.statements
    assert len(stmts) == 6, len(stmts)
    for s in stmts:
        assert len(s.evidence) == 1, "Wrong amount of evidence."
        ev = s.evidence[0]
        assert ev.annotations, "Missing annotations."
        assert 'agents' in ev.annotations.keys()
        assert 'trigger' in ev.annotations.keys()


def test_ungrounded_usage():
    rp = rlimsp.process_from_webservice('PMC3717945', with_grounding=False)
    assert len(rp.statements) == 33, len(rp.statements)


def test_ungrounded_endpoint_with_pmids():
    pmid_list = ['16403219', '22258404', '16961925', '22096607']
    stmts = []
    for pmid in pmid_list:
        rp = rlimsp.process_from_webservice(pmid, id_type='pmid',
                                            with_grounding=False)
        assert len(rp.statements) > 10, len(rp.statements)
        stmts.extend(rp.statements)
    assert len(stmts) == 394, len(stmts)
    return


def test_grounded_endpoint_with_pmids():
    pmid_list = ['16403219', '22258404', '16961925', '22096607']
    stmts = []
    for pmid in pmid_list:
        rp = rlimsp.process_from_webservice(pmid, id_type='pmid')
        assert len(rp.statements), len(rp.statements)
        stmts.extend(rp.statements)
    assert len(stmts) > 10, len(stmts)


def test_ungrounded_endpoint_with_pmids_on_medline():
    pmid_list = ['16403219', '22258404', '16961925', '22096607']
    for pmid in pmid_list:
        rp = rlimsp.process_from_webservice(pmid, id_type='pmid',
                                            source='medline')


def test_grounded_endpoint_with_pmids_on_medline():
    pmid_list = ['16403219', '22258404', '16961925', '22096607']
    for pmid in pmid_list:
        rp = rlimsp.process_from_webservice(pmid, id_type='pmid',
                                            source='medline',
                                            with_grounding=False)


def test_tyrosine_grounding():
    here = os.path.dirname(os.path.abspath(__file__))
    fname = os.path.join(here, 'rlimsp_site.json')
    rp = rlimsp.process_from_json_file(fname)
    assert len(rp.statements) == 1
    stmt = rp.statements[0]
    assert stmt.residue == 'Y'
    assert stmt.position == '705'

@@ -37,16 +37,17 @@
 rlimsp%0A%0A
+%0A
 def test
@@ -168,17 +168,18 @@
 mts) == 
-6
+33
 , len(st
@@ -454,171 +454,8 @@
 )%0A%0A%0A
-def test_ungrounded_usage():%0A    rp = rlimsp.process_from_webservice('PMC3717945', with_grounding=False)%0A    assert len(rp.statements) == 33, len(rp.statements)%0A%0A%0A
 def 
@@ -668,74 +668,8 @@
 mid'
-,%0A                                            with_grounding=False
 )%0A  
@@ -798,24 +798,24 @@
  len(stmts)%0A
+
     return%0A%0A
@@ -819,969 +819,8 @@
 n%0A%0A%0A
-def test_grounded_endpoint_with_pmids():%0A    pmid_list = %5B'16403219', '22258404', '16961925', '22096607'%5D%0A    stmts = %5B%5D%0A    for pmid in pmid_list:%0A        rp = rlimsp.process_from_webservice(pmid, id_type='pmid')%0A        assert len(rp.statements), len(rp.statements)%0A        stmts.extend(rp.statements)%0A    assert len(stmts) %3E 10, len(stmts)%0A%0A%0Adef test_ungrounded_endpoint_with_pmids_on_medline():%0A    pmid_list = %5B'16403219', '22258404', '16961925', '22096607'%5D%0A    for pmid in pmid_list:%0A        rp = rlimsp.process_from_webservice(pmid, id_type='pmid',%0A                                            source='medline')%0A%0A%0Adef test_grounded_endpoint_with_pmids_on_medline():%0A    pmid_list = %5B'16403219', '22258404', '16961925', '22096607'%5D%0A    for pmid in pmid_list:%0A        rp = rlimsp.process_from_webservice(pmid, id_type='pmid',%0A                                            source='medline',%0A                                            with_grounding=False)%0A%0A%0A
 def 

Remove deprecated endpoints from tests