from __future__ import absolute_import, print_function, unicode_literals
from builtins import dict, str
from indra.statements import Agent
from indra.databases import chembl_client
from indra.util import unicode_strs

vem = Agent('VEMURAFENIB', db_refs={'CHEBI': '63637', 'TEXT': 'VEMURAFENIB'})
az628 = Agent('AZ628', db_refs={'CHEBI': '91354'})
braf = Agent('BRAF', db_refs={'HGNC': '1097', 'NCIT': 'C51194',
                              'TEXT': 'BRAF', 'UP': 'P15056'})

def test_get_inhibitions():
    stmt = chembl_client.get_inhibition(vem, braf)
    assert(stmt is not None)
    assert(unicode_strs(stmt))
    assert(len(stmt.evidence) > 5)
    for ev in stmt.evidence:
        assert(ev.pmid)
        assert(ev.annotations)
        assert(ev.source_api == 'chembl')
        assert(ev.source_id)


def test_get_drug_inhibition_stmts_vem():
    stmts = chembl_client.get_drug_inhibition_stmts(vem)
    assert(len(stmts) > 0)
    for st in stmts:
        assert(unicode_strs(st))
        assert(len(st.evidence) >= 1)
        for ev in st.evidence:
            assert(ev.pmid)
            assert(ev.annotations)
            assert(ev.source_api == 'chembl')
            assert(ev.source_id)


def test_get_drug_inhibition_stmts_az628():
    stmts = chembl_client.get_drug_inhibition_stmts(az628)
    assert(len(stmts) > 0)
    for st in stmts:
        assert(unicode_strs(st))
        assert(len(st.evidence) >= 1)
        for ev in st.evidence:
            assert(ev.pmid)
            assert(ev.annotations)
            assert(ev.source_api == 'chembl')
            assert(ev.source_id)

@@ -466,16 +466,231 @@
 15056'%7D)
+%0Abraf_chembl_id = 'CHEMBL1229517'%0Aquery_dict_BRAF_activity = %7B'query': 'activity',%0A                            'params': %7B'molecule_chembl_id': braf_chembl_id,%0A                                       'limit': 10000%7D%7D
 %0A%0Adef te
@@ -1006,32 +1006,397 @@
 ev.source_id)%0A%0A%0A
+def test_activity_query():%0A    res = chembl_client.send_query(query_dict_BRAF_activity)%0A    assert(res%5B'page_meta'%5D%5B'total_count'%5D == len(res%5B'activities'%5D))%0A    assay_types = list(set(%5Bx%5B'standard_type'%5D for x in res%5B'activities'%5D%5D))%0A    expected_types = %5B'IC50', 'EC50', 'INH', 'Potency', 'Kd'%5D%0A    for e_t in expected_types:%0A        assert(e_t in assay_types)%0A%0A%0A
 def test_get_dru

Test send_query using activity endpoint