<s> import time <EOL> import unittest <EOL> from suricate . analytics import exec_node , proj_ntb_store <EOL> class ExecNodeTest ( unittest . TestCase ) : <EOL> payload = { '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT:bar>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> mongo_uri = '<STR_LIT>' <EOL> amqp_uri = '<STR_LIT>' <EOL> def setUp ( self ) : <EOL> self . store = proj_ntb_store . NotebookStore ( self . mongo_uri , '<STR_LIT:foo>' ) <EOL> self . cut = ClassUnderTestWrapper ( self . mongo_uri , self . amqp_uri , <EOL> '<STR_LIT>' , '<STR_LIT:foo>' ) <EOL> self . ntb_id = self . store . update_notebook ( '<STR_LIT>' , <EOL> None , <EOL> { '<STR_LIT:src>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ ] } } , <EOL> '<STR_LIT:foo>' , '<STR_LIT:bar>' ) <EOL> def tearDown ( self ) : <EOL> self . store . delete_project ( '<STR_LIT>' , '<STR_LIT:foo>' , '<STR_LIT:bar>' ) <EOL> def test_handle_for_sanity ( self ) : <EOL> self . payload [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertTrue ( '<STR_LIT>' in self . cut . _handle ( self . payload ) [ '<STR_LIT>' ] ) <EOL> self . payload [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertEquals ( self . cut . _handle ( self . payload ) [ '<STR_LIT>' ] , <EOL> [ ( self . ntb_id , { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : [ ] } ) ] ) <EOL> self . payload [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . payload [ '<STR_LIT>' ] = self . ntb_id <EOL> self . assertEqual ( self . cut . _handle ( self . payload ) [ '<STR_LIT>' ] [ '<STR_LIT:src>' ] , <EOL> '<STR_LIT>' ) <EOL> self . payload [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . payload [ '<STR_LIT>' ] = self . ntb_id <EOL> self . payload [ '<STR_LIT:src>' ] = '<STR_LIT>' <EOL> self . assertEqual ( self . cut . _handle ( self . payload ) , { } ) <EOL> self . payload [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertEquals ( self . cut . _handle ( self . payload ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> [ '<STR_LIT:hello>' ] ) <EOL> self . payload [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . payload [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertEqual ( self . cut . _handle ( self . payload ) , { } ) <EOL> self . payload [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . payload [ '<STR_LIT>' ] = self . ntb_id <EOL> self . payload [ '<STR_LIT:src>' ] = '<STR_LIT>' <EOL> self . cut . _handle ( self . payload ) <EOL> self . payload [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertEquals ( self . cut . _handle ( self . payload ) [ '<STR_LIT>' ] [ '<STR_LIT:src>' ] , <EOL> '<STR_LIT>' ) <EOL> self . payload [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . payload [ '<STR_LIT>' ] = self . ntb_id <EOL> self . payload [ '<STR_LIT:src>' ] = '<STR_LIT>' '<STR_LIT>' <EOL> self . cut . _handle ( self . payload ) <EOL> self . payload [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> time . sleep ( <NUM_LIT:2> ) <EOL> self . assertEquals ( self . cut . _handle ( self . payload ) [ '<STR_LIT>' ] . values ( ) [ <NUM_LIT:0> ] , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:state>' : '<STR_LIT>' , '<STR_LIT>' : self . ntb_id } ) <EOL> time . sleep ( <NUM_LIT:10> ) <EOL> tmp = self . cut . _handle ( self . payload ) [ '<STR_LIT>' ] . values ( ) [ <NUM_LIT:0> ] <EOL> self . assertEquals ( tmp [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEquals ( tmp [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEquals ( tmp [ '<STR_LIT>' ] , self . ntb_id ) <EOL> self . assertIsNot ( tmp [ '<STR_LIT:state>' ] . find ( '<STR_LIT>' ) , - <NUM_LIT:1> ) <EOL> self . payload [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertEquals ( self . cut . _handle ( self . payload ) [ '<STR_LIT>' ] [ '<STR_LIT:src>' ] , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . payload [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . payload [ '<STR_LIT>' ] = self . ntb_id <EOL> self . cut . _handle ( self . payload ) <EOL> class ClassUnderTestWrapper ( exec_node . ExecNode ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , mongo_uri , amqp_uri , sdk , uid ) : <EOL> self . uid = uid <EOL> self . uri = mongo_uri <EOL> self . sdk = sdk <EOL> self . stor = proj_ntb_store . NotebookStore ( mongo_uri , '<STR_LIT:foo>' ) </s>
