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_submit_statement(): ##Tests to see if a single statement can be inserted tc = TinCan(USER_NAME,PASSWORD,ENDPOINT) statement_ID = str(uuid.uuid1()) whoDid = "I" whoDidEmail = "*****@*****.**" whoDidObject = 'you' didWhat = 'created' ##Build the Tin Can statement createdJsonObject ={ "id": statement_ID, 'actor':{'name':[whoDid],'mbox':['mailto:'+whoDidEmail]}, 'verb':didWhat, 'object':{'id':str(uuid.uuid1()),'definition':{'name':{"en-US":whoDidObject},'description':{"en-US":'Testing single insertion of a statement.'}}} } tc.submitStatement(createdJsonObject) ##Sleeps to insure the statement is inserted time.sleep(10) ##Gets the statement by the ID used when inserted testStatement = tc.getStatementbyID(statement_ID) ##Ensures the ID when inserted and the ID on the retrieve are the same assert (testStatement['id'] == statement_ID)