def testComplexFilter(): ##Ensures a complex filter returns correct data tc = TinCan(USER_NAME,PASSWORD,ENDPOINT) whoDid = "Complex Test" statement_ID = str(uuid.uuid1()) whoDidEmail = "*****@*****.**" whoDidObject = 'Test Subject' didWhat = 'attempted' now = datetime.datetime.now() x={'mbox':['mailto:'+whoDidEmail]} ##Inserts object to filter for createdJsonObject = { 'id': statement_ID, 'actor':{'name':[whoDid],'mbox':['mailto:'+whoDidEmail]}, 'verb':didWhat, 'object':{'id':str(uuid.uuid1()),'definition':{'name':{"en-US":'with '+whoDidObject},'description':{"en-US":'Inserting a description for a complex filter.'}}} } ##Inserts statement tc.submitStatement(createdJsonObject) time.sleep(8) results = tc.getFilteredStatements(_verb=didWhat,_actor=x,_limit=1,_sparse=True,_since=str(now)) for result in results['statements']: if result['verb']==didWhat: for x in result['actor']['mbox']: assert (x == 'mailto:'+whoDidEmail.lower())
def test_filter_statements(): ##Ensures a simple filter request returns the correct information tc = TinCan(USER_NAME,PASSWORD,ENDPOINT) test_verb = 'created' email = '*****@*****.**' x={'mbox':['mailto:'+email]} results = tc.getFilteredStatements(_actor=x,_limit=5, _sparse=True) for result in results['statements']: for emails in result['actor']['mbox']: if (emails=='mailto:'+email.lower()) : assert True