<s> import ast <EOL> import datetime <EOL> import decimal <EOL> import json <EOL> from django . core . exceptions import FieldError <EOL> import mox <EOL> from stacktach import datetime_to_decimal as dt <EOL> from stacktach import models <EOL> from stacktach import stacky_server <EOL> import utils <EOL> from utils import INSTANCE_ID_1 , INSTANCE_TYPE_ID_1 <EOL> from utils import INSTANCE_FLAVOR_ID_1 <EOL> from utils import INSTANCE_ID_2 <EOL> from utils import REQUEST_ID_1 <EOL> from tests . unit import StacktachBaseTestCase <EOL> class StackyServerTestCase ( StacktachBaseTestCase ) : <EOL> def setUp ( self ) : <EOL> self . mox = mox . Mox ( ) <EOL> self . mox . StubOutWithMock ( models , '<STR_LIT>' , use_mock_anything = True ) <EOL> models . RawData . objects = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( models , '<STR_LIT>' , use_mock_anything = True ) <EOL> self . mox . StubOutWithMock ( models , '<STR_LIT>' , <EOL> use_mock_anything = True ) <EOL> models . GlanceRawData . objects = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( models , '<STR_LIT>' , <EOL> use_mock_anything = True ) <EOL> models . GenericRawData . objects = self . mox . CreateMockAnything ( ) <EOL> models . Deployment . objects = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( models , '<STR_LIT>' , use_mock_anything = True ) <EOL> models . Lifecycle . objects = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( models , '<STR_LIT>' , use_mock_anything = True ) <EOL> models . Timing . objects = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( models , '<STR_LIT>' , <EOL> use_mock_anything = True ) <EOL> models . RequestTracker . objects = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( models , '<STR_LIT>' , <EOL> use_mock_anything = True ) <EOL> models . InstanceUsage . objects = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( models , '<STR_LIT>' , <EOL> use_mock_anything = True ) <EOL> models . InstanceDeletes . objects = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( models , '<STR_LIT>' , <EOL> use_mock_anything = True ) <EOL> models . InstanceExists . objects = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( models , '<STR_LIT>' , use_mock_anything = True ) <EOL> models . JsonReport . objects = self . mox . CreateMockAnything ( ) <EOL> def tearDown ( self ) : <EOL> self . mox . UnsetStubs ( ) <EOL> def _create_raw ( self ) : <EOL> raw = self . mox . CreateMockAnything ( ) <EOL> raw . when = utils . decimal_utc ( datetime . datetime ( <NUM_LIT> , <NUM_LIT:7> , <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:16> , <EOL> <NUM_LIT:10> , <NUM_LIT> ) ) <EOL> raw . instance = INSTANCE_ID_1 <EOL> raw . id = <NUM_LIT:1> <EOL> raw . routing_key = '<STR_LIT>' <EOL> raw . deployment = self . mox . CreateMockAnything ( ) <EOL> raw . deployment . id = <NUM_LIT:1> <EOL> raw . deployment . name = '<STR_LIT>' <EOL> raw . event = '<STR_LIT>' <EOL> raw . host = '<STR_LIT>' <EOL> raw . state = '<STR_LIT>' <EOL> raw . old_state = None <EOL> raw . old_task = None <EOL> raw . publisher = "<STR_LIT>" <EOL> raw . service = '<STR_LIT>' <EOL> raw . host = '<STR_LIT>' <EOL> raw . status = '<STR_LIT:state>' <EOL> raw . request_id = REQUEST_ID_1 <EOL> raw . json = '<STR_LIT>' <EOL> raw . uuid = '<STR_LIT>' <EOL> raw . tenant = '<STR_LIT>' <EOL> return raw <EOL> def test_get_event_names ( self ) : <EOL> model = self . mox . CreateMockAnything ( ) <EOL> result = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> stacky_server . _model_factory ( '<STR_LIT>' ) . AndReturn ( model ) <EOL> model . values ( '<STR_LIT>' ) . AndReturn ( result ) <EOL> result . distinct ( ) . AndReturn ( result ) <EOL> self . mox . ReplayAll ( ) <EOL> event_names = stacky_server . get_event_names ( ) <EOL> self . assertEqual ( event_names , result ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_get_host_names_for_nova ( self ) : <EOL> result = self . mox . CreateMockAnything ( ) <EOL> models . RawData . objects . values ( '<STR_LIT:host>' ) . AndReturn ( result ) <EOL> result . distinct ( ) . AndReturn ( result ) <EOL> self . mox . ReplayAll ( ) <EOL> event_names = stacky_server . get_host_names ( '<STR_LIT>' ) <EOL> self . assertEqual ( event_names , result ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_get_host_names_for_glance ( self ) : <EOL> result = self . mox . CreateMockAnything ( ) <EOL> models . GlanceRawData . objects . values ( '<STR_LIT:host>' ) . AndReturn ( result ) <EOL> result . distinct ( ) . AndReturn ( result ) <EOL> self . mox . ReplayAll ( ) <EOL> event_names = stacky_server . get_host_names ( '<STR_LIT>' ) <EOL> self . assertEqual ( event_names , result ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_get_deployments ( self ) : <EOL> result = self . mox . CreateMockAnything ( ) <EOL> models . Deployment . objects . all ( ) . AndReturn ( result ) <EOL> result . order_by ( '<STR_LIT:name>' ) . AndReturn ( result ) <EOL> self . mox . ReplayAll ( ) <EOL> event_names = stacky_server . get_deployments ( ) <EOL> self . assertEqual ( event_names , result ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_get_timings_for_uuid_start_only ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { } <EOL> lc_result = self . mox . CreateMockAnything ( ) <EOL> lifecycle = self . mox . CreateMockAnything ( ) <EOL> models . Lifecycle . objects . filter ( instance = INSTANCE_ID_1 ) . AndReturn ( lc_result ) <EOL> lc_result [ None : <NUM_LIT:50> ] . AndReturn ( lc_result ) <EOL> lc_result . __iter__ ( ) . AndReturn ( [ lifecycle ] . __iter__ ( ) ) <EOL> t_result = self . mox . CreateMockAnything ( ) <EOL> timing = self . mox . CreateMockAnything ( ) <EOL> models . Timing . objects . filter ( lifecycle = lifecycle ) . AndReturn ( t_result ) <EOL> t_result . __iter__ ( ) . AndReturn ( [ timing ] . __iter__ ( ) ) <EOL> timing . name = '<STR_LIT:name>' <EOL> timing . start_raw = self . mox . CreateMockAnything ( ) <EOL> timing . end_raw = None <EOL> timing . diff = None <EOL> self . mox . ReplayAll ( ) <EOL> event_names = stacky_server . get_timings_for_uuid ( fake_request , <EOL> INSTANCE_ID_1 ) <EOL> self . assertEqual ( len ( event_names ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( event_names [ <NUM_LIT:0> ] , [ '<STR_LIT:?>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( event_names [ <NUM_LIT:1> ] , [ '<STR_LIT:S>' , '<STR_LIT:name>' , '<STR_LIT>' ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_get_timings_for_uuid_end_only ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { } <EOL> lc_result = self . mox . CreateMockAnything ( ) <EOL> lifecycle = self . mox . CreateMockAnything ( ) <EOL> models . Lifecycle . objects . filter ( instance = INSTANCE_ID_1 ) . AndReturn ( lc_result ) <EOL> lc_result [ None : <NUM_LIT:50> ] . AndReturn ( lc_result ) <EOL> lc_result . __iter__ ( ) . AndReturn ( [ lifecycle ] . __iter__ ( ) ) <EOL> t_result = self . mox . CreateMockAnything ( ) <EOL> timing = self . mox . CreateMockAnything ( ) <EOL> models . Timing . objects . filter ( lifecycle = lifecycle ) . AndReturn ( t_result ) <EOL> t_result . __iter__ ( ) . AndReturn ( [ timing ] . __iter__ ( ) ) <EOL> timing . name = '<STR_LIT:name>' <EOL> timing . start_raw = None <EOL> timing . end_raw = self . mox . CreateMockAnything ( ) <EOL> timing . diff = None <EOL> self . mox . ReplayAll ( ) <EOL> event_names = stacky_server . get_timings_for_uuid ( fake_request , <EOL> INSTANCE_ID_1 ) <EOL> self . assertEqual ( len ( event_names ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( event_names [ <NUM_LIT:0> ] , [ '<STR_LIT:?>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( event_names [ <NUM_LIT:1> ] , [ '<STR_LIT:E>' , '<STR_LIT:name>' , '<STR_LIT>' ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_get_timings_for_uuid ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { } <EOL> lc_result = self . mox . CreateMockAnything ( ) <EOL> lifecycle = self . mox . CreateMockAnything ( ) <EOL> models . Lifecycle . objects . filter ( instance = INSTANCE_ID_1 ) . AndReturn ( lc_result ) <EOL> lc_result [ None : <NUM_LIT:50> ] . AndReturn ( lc_result ) <EOL> lc_result . __iter__ ( ) . AndReturn ( [ lifecycle ] . __iter__ ( ) ) <EOL> t_result = self . mox . CreateMockAnything ( ) <EOL> timing = self . mox . CreateMockAnything ( ) <EOL> models . Timing . objects . filter ( lifecycle = lifecycle ) . AndReturn ( t_result ) <EOL> t_result . __iter__ ( ) . AndReturn ( [ timing ] . __iter__ ( ) ) <EOL> timing . name = '<STR_LIT:name>' <EOL> timing . start_raw = self . mox . CreateMockAnything ( ) <EOL> timing . end_raw = self . mox . CreateMockAnything ( ) <EOL> timing . diff = <NUM_LIT:20> <EOL> self . mox . ReplayAll ( ) <EOL> event_names = stacky_server . get_timings_for_uuid ( fake_request , <EOL> INSTANCE_ID_1 ) <EOL> self . assertEqual ( len ( event_names ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( event_names [ <NUM_LIT:0> ] , [ '<STR_LIT:?>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( event_names [ <NUM_LIT:1> ] , [ '<STR_LIT:.>' , '<STR_LIT:name>' , '<STR_LIT>' ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_deployments ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> deployment1 = self . mox . CreateMockAnything ( ) <EOL> deployment1 . id = <NUM_LIT:1> <EOL> deployment1 . name = '<STR_LIT>' <EOL> deployment2 = self . mox . CreateMockAnything ( ) <EOL> deployment2 . id = <NUM_LIT:2> <EOL> deployment2 . name = '<STR_LIT>' <EOL> deployments = [ deployment1 , deployment2 ] <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> stacky_server . get_deployments ( ) . AndReturn ( deployments ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_deployments ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , [ '<STR_LIT:#>' , '<STR_LIT:Name>' ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] , [ <NUM_LIT:1> , '<STR_LIT>' ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:2> ] , [ <NUM_LIT:2> , '<STR_LIT>' ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_events_of_a_single_service ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : '<STR_LIT>' } <EOL> event1 = { '<STR_LIT>' : '<STR_LIT>' } <EOL> event2 = { '<STR_LIT>' : '<STR_LIT>' } <EOL> events = [ event1 , event2 ] <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> stacky_server . get_event_names ( service = '<STR_LIT>' ) . AndReturn ( events ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_events ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] , [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:2> ] , [ '<STR_LIT>' ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_events_of_all_services ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : '<STR_LIT:all>' } <EOL> event1 = { '<STR_LIT>' : '<STR_LIT>' } <EOL> event2 = { '<STR_LIT>' : '<STR_LIT>' } <EOL> events = [ event1 , event2 ] <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> stacky_server . get_event_names ( '<STR_LIT>' ) . AndReturn ( events ) <EOL> stacky_server . get_event_names ( '<STR_LIT>' ) . AndReturn ( events ) <EOL> stacky_server . get_event_names ( '<STR_LIT>' ) . AndReturn ( events ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_events ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:7> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] , [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:2> ] , [ '<STR_LIT>' ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_hosts ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : '<STR_LIT>' } <EOL> host1 = { '<STR_LIT:host>' : '<STR_LIT>' } <EOL> host2 = { '<STR_LIT:host>' : '<STR_LIT>' } <EOL> hosts = [ host1 , host2 ] <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> stacky_server . get_host_names ( '<STR_LIT>' ) . AndReturn ( hosts ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_hosts ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] , [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:2> ] , [ '<STR_LIT>' ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_uuid ( self ) : <EOL> search_result = [ [ "<STR_LIT:#>" , "<STR_LIT:?>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , [ <NUM_LIT:1> , "<STR_LIT:U+0020>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , None , None ] ] <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : INSTANCE_ID_1 } <EOL> result = self . mox . CreateMockAnything ( ) <EOL> models . RawData . objects . select_related ( ) . AndReturn ( result ) <EOL> result . filter ( instance = INSTANCE_ID_1 ) . AndReturn ( result ) <EOL> result . order_by ( '<STR_LIT>' ) . AndReturn ( result ) <EOL> raw = self . _create_raw ( ) <EOL> result [ None : <NUM_LIT:50> ] . AndReturn ( result ) <EOL> result . __iter__ ( ) . AndReturn ( [ raw ] . __iter__ ( ) ) <EOL> raw . search_results ( [ ] , mox . IgnoreArg ( ) , '<STR_LIT:U+0020>' ) . AndReturn ( search_result ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_uuid ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:2> ) <EOL> header = [ "<STR_LIT:#>" , "<STR_LIT:?>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , header ) <EOL> datetime = dt . dt_from_decimal ( raw . when ) <EOL> body = [ <NUM_LIT:1> , "<STR_LIT:U+0020>" , str ( datetime ) , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , None , None ] <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] , body ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_uuid_when_filters ( self ) : <EOL> search_result = [ [ "<STR_LIT:#>" , "<STR_LIT:?>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , [ <NUM_LIT:1> , "<STR_LIT:U+0020>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , None , None ] ] <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : INSTANCE_ID_1 , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> result = self . mox . CreateMockAnything ( ) <EOL> models . RawData . objects . select_related ( ) . AndReturn ( result ) <EOL> result . filter ( instance = INSTANCE_ID_1 , <EOL> when__gte = decimal . Decimal ( '<STR_LIT>' ) , <EOL> when__lte = decimal . Decimal ( '<STR_LIT>' ) ) . AndReturn ( result ) <EOL> result . order_by ( '<STR_LIT>' ) . AndReturn ( result ) <EOL> raw = self . _create_raw ( ) <EOL> result [ None : <NUM_LIT:50> ] . AndReturn ( result ) <EOL> result . __iter__ ( ) . AndReturn ( [ raw ] . __iter__ ( ) ) <EOL> raw . search_results ( [ ] , mox . IgnoreArg ( ) , '<STR_LIT:U+0020>' ) . AndReturn ( search_result ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_uuid ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:2> ) <EOL> header = [ "<STR_LIT:#>" , "<STR_LIT:?>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , header ) <EOL> datetime = dt . dt_from_decimal ( raw . when ) <EOL> body = [ <NUM_LIT:1> , "<STR_LIT:U+0020>" , str ( datetime ) , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , None , None ] <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] , body ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_uuid_for_glance ( self ) : <EOL> search_result = [ [ "<STR_LIT:#>" , "<STR_LIT:?>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ] , [ <NUM_LIT:1> , "<STR_LIT:U+0020>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:state>" ] ] <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : INSTANCE_ID_1 , '<STR_LIT>' : '<STR_LIT>' } <EOL> result = self . mox . CreateMockAnything ( ) <EOL> models . GlanceRawData . objects . select_related ( ) . AndReturn ( result ) <EOL> result . filter ( uuid = INSTANCE_ID_1 ) . AndReturn ( result ) <EOL> result . order_by ( '<STR_LIT>' ) . AndReturn ( result ) <EOL> raw = self . _create_raw ( ) <EOL> result [ None : <NUM_LIT:50> ] . AndReturn ( result ) <EOL> result . __iter__ ( ) . AndReturn ( [ raw ] . __iter__ ( ) ) <EOL> raw . search_results ( [ ] , mox . IgnoreArg ( ) , '<STR_LIT:U+0020>' ) . AndReturn ( search_result ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_uuid ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:2> ) <EOL> header = [ "<STR_LIT:#>" , "<STR_LIT:?>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ] <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , header ) <EOL> datetime = dt . dt_from_decimal ( raw . when ) <EOL> body = [ <NUM_LIT:1> , "<STR_LIT:U+0020>" , str ( datetime ) , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT:state>" ] <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] , body ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_uuid_for_glance_when_filters ( self ) : <EOL> search_result = [ [ "<STR_LIT:#>" , "<STR_LIT:?>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ] , [ <NUM_LIT:1> , "<STR_LIT:U+0020>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:state>" ] ] <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : INSTANCE_ID_1 , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> result = self . mox . CreateMockAnything ( ) <EOL> models . GlanceRawData . objects . select_related ( ) . AndReturn ( result ) <EOL> result . filter ( uuid = INSTANCE_ID_1 , <EOL> when__gte = decimal . Decimal ( '<STR_LIT>' ) , <EOL> when__lte = decimal . Decimal ( '<STR_LIT>' ) ) . AndReturn ( result ) <EOL> result . order_by ( '<STR_LIT>' ) . AndReturn ( result ) <EOL> raw = self . _create_raw ( ) <EOL> result [ None : <NUM_LIT:50> ] . AndReturn ( result ) <EOL> result . __iter__ ( ) . AndReturn ( [ raw ] . __iter__ ( ) ) <EOL> raw . search_results ( [ ] , mox . IgnoreArg ( ) , '<STR_LIT:U+0020>' ) . AndReturn ( search_result ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_uuid ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:2> ) <EOL> header = [ "<STR_LIT:#>" , "<STR_LIT:?>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ] <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , header ) <EOL> datetime = dt . dt_from_decimal ( raw . when ) <EOL> body = [ <NUM_LIT:1> , "<STR_LIT:U+0020>" , str ( datetime ) , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT:state>" ] <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] , body ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_uuid_bad_uuid ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : "<STR_LIT>" } <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_uuid ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT> ) <EOL> resp_json = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( resp_json ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( resp_json [ <NUM_LIT:0> ] , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> msg = '<STR_LIT>' <EOL> self . assertEqual ( resp_json [ <NUM_LIT:1> ] , [ '<STR_LIT>' , msg ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_timings_uuid_bad_uuid ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : "<STR_LIT>" } <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_timings_uuid ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT> ) <EOL> resp_json = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( resp_json ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( resp_json [ <NUM_LIT:0> ] , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> msg = '<STR_LIT>' <EOL> self . assertEqual ( resp_json [ <NUM_LIT:1> ] , [ '<STR_LIT>' , msg ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_timings ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT:name>' : '<STR_LIT>' } <EOL> results = self . mox . CreateMockAnything ( ) <EOL> models . Timing . objects . select_related ( ) . AndReturn ( results ) <EOL> results . filter ( name = '<STR_LIT>' ) . AndReturn ( results ) <EOL> results . exclude ( mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . order_by ( '<STR_LIT>' ) . AndReturn ( results ) <EOL> timing1 = self . mox . CreateMockAnything ( ) <EOL> timing1 . lifecycle = self . mox . CreateMockAnything ( ) <EOL> timing1 . lifecycle . instance = INSTANCE_ID_1 <EOL> timing1 . diff = <NUM_LIT:10> <EOL> timing2 = self . mox . CreateMockAnything ( ) <EOL> timing2 . lifecycle = self . mox . CreateMockAnything ( ) <EOL> timing2 . lifecycle . instance = INSTANCE_ID_2 <EOL> timing2 . diff = <NUM_LIT:20> <EOL> results [ None : <NUM_LIT:50> ] . AndReturn ( results ) <EOL> results . __iter__ ( ) . AndReturn ( [ timing1 , timing2 ] . __iter__ ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_timings ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:3> ) <EOL> header = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , header ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] , [ INSTANCE_ID_1 , '<STR_LIT>' ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:2> ] , [ INSTANCE_ID_2 , '<STR_LIT>' ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_timings_end_when_min ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> results = self . mox . CreateMockAnything ( ) <EOL> models . Timing . objects . select_related ( ) . AndReturn ( results ) <EOL> results . filter ( name = '<STR_LIT>' , <EOL> end_when__gte = decimal . Decimal ( '<STR_LIT>' ) ) . AndReturn ( results ) <EOL> results . exclude ( mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . order_by ( '<STR_LIT>' ) . AndReturn ( results ) <EOL> timing1 = self . mox . CreateMockAnything ( ) <EOL> timing1 . lifecycle = self . mox . CreateMockAnything ( ) <EOL> timing1 . lifecycle . instance = INSTANCE_ID_1 <EOL> timing1 . diff = <NUM_LIT:10> <EOL> timing2 = self . mox . CreateMockAnything ( ) <EOL> timing2 . lifecycle = self . mox . CreateMockAnything ( ) <EOL> timing2 . lifecycle . instance = INSTANCE_ID_2 <EOL> timing2 . diff = <NUM_LIT:20> <EOL> results [ None : <NUM_LIT:50> ] . AndReturn ( results ) <EOL> results . __iter__ ( ) . AndReturn ( [ timing1 , timing2 ] . __iter__ ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_timings ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:3> ) <EOL> header = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , header ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] , [ INSTANCE_ID_1 , '<STR_LIT>' ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:2> ] , [ INSTANCE_ID_2 , '<STR_LIT>' ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_timings_end_when_max ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> results = self . mox . CreateMockAnything ( ) <EOL> models . Timing . objects . select_related ( ) . AndReturn ( results ) <EOL> results . filter ( name = '<STR_LIT>' , <EOL> end_when__lte = decimal . Decimal ( '<STR_LIT>' ) ) . AndReturn ( results ) <EOL> results . exclude ( mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . order_by ( '<STR_LIT>' ) . AndReturn ( results ) <EOL> timing1 = self . mox . CreateMockAnything ( ) <EOL> timing1 . lifecycle = self . mox . CreateMockAnything ( ) <EOL> timing1 . lifecycle . instance = INSTANCE_ID_1 <EOL> timing1 . diff = <NUM_LIT:10> <EOL> timing2 = self . mox . CreateMockAnything ( ) <EOL> timing2 . lifecycle = self . mox . CreateMockAnything ( ) <EOL> timing2 . lifecycle . instance = INSTANCE_ID_2 <EOL> timing2 . diff = <NUM_LIT:20> <EOL> results [ None : <NUM_LIT:50> ] . AndReturn ( results ) <EOL> results . __iter__ ( ) . AndReturn ( [ timing1 , timing2 ] . __iter__ ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_timings ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:3> ) <EOL> header = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , header ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] , [ INSTANCE_ID_1 , '<STR_LIT>' ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:2> ] , [ INSTANCE_ID_2 , '<STR_LIT>' ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_timings_end_when_max_when_min ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> results = self . mox . CreateMockAnything ( ) <EOL> models . Timing . objects . select_related ( ) . AndReturn ( results ) <EOL> results . filter ( name = '<STR_LIT>' , <EOL> end_when__gte = decimal . Decimal ( '<STR_LIT>' ) , <EOL> end_when__lte = decimal . Decimal ( '<STR_LIT>' ) ) . AndReturn ( results ) <EOL> results . exclude ( mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . order_by ( '<STR_LIT>' ) . AndReturn ( results ) <EOL> timing1 = self . mox . CreateMockAnything ( ) <EOL> timing1 . lifecycle = self . mox . CreateMockAnything ( ) <EOL> timing1 . lifecycle . instance = INSTANCE_ID_1 <EOL> timing1 . diff = <NUM_LIT:10> <EOL> timing2 = self . mox . CreateMockAnything ( ) <EOL> timing2 . lifecycle = self . mox . CreateMockAnything ( ) <EOL> timing2 . lifecycle . instance = INSTANCE_ID_2 <EOL> timing2 . diff = <NUM_LIT:20> <EOL> results [ None : <NUM_LIT:50> ] . AndReturn ( results ) <EOL> results . __iter__ ( ) . AndReturn ( [ timing1 , timing2 ] . __iter__ ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_timings ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:3> ) <EOL> header = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , header ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] , [ INSTANCE_ID_1 , '<STR_LIT>' ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:2> ] , [ INSTANCE_ID_2 , '<STR_LIT>' ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_summary ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> events = [ { '<STR_LIT>' : '<STR_LIT>' } , { '<STR_LIT>' : '<STR_LIT>' } ] <EOL> stacky_server . get_event_names ( ) . AndReturn ( events ) <EOL> fake_request . GET = { '<STR_LIT:name>' : '<STR_LIT>' } <EOL> results = self . mox . CreateMockAnything ( ) <EOL> models . Timing . objects . filter ( name = '<STR_LIT:test>' ) . AndReturn ( results ) <EOL> results . exclude ( mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . exclude ( diff__lt = <NUM_LIT:0> ) . AndReturn ( results ) <EOL> timing1 = self . mox . CreateMockAnything ( ) <EOL> timing1 . lifecycle = self . mox . CreateMockAnything ( ) <EOL> timing1 . lifecycle . instance = INSTANCE_ID_1 <EOL> timing1 . diff = <NUM_LIT:10> <EOL> timing2 = self . mox . CreateMockAnything ( ) <EOL> timing2 . lifecycle = self . mox . CreateMockAnything ( ) <EOL> timing2 . lifecycle . instance = INSTANCE_ID_2 <EOL> timing2 . diff = <NUM_LIT:20> <EOL> results [ None : <NUM_LIT:50> ] . AndReturn ( results ) <EOL> results . __len__ ( ) . AndReturn ( <NUM_LIT:2> ) <EOL> results . __iter__ ( ) . AndReturn ( [ timing1 , timing2 ] . __iter__ ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_summary ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , [ "<STR_LIT>" , "<STR_LIT:N>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] , [ u'<STR_LIT:test>' , <NUM_LIT:2> , u'<STR_LIT>' , <EOL> u'<STR_LIT>' , u'<STR_LIT>' ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_request ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : REQUEST_ID_1 } <EOL> raw = self . _create_raw ( ) <EOL> results = self . mox . CreateMockAnything ( ) <EOL> models . RawData . objects . filter ( request_id = REQUEST_ID_1 ) . AndReturn ( results ) <EOL> results . order_by ( '<STR_LIT>' ) . AndReturn ( results ) <EOL> results [ None : <NUM_LIT:50> ] . AndReturn ( results ) <EOL> results . __iter__ ( ) . AndReturn ( [ raw ] . __iter__ ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_request ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , [ "<STR_LIT:#>" , "<STR_LIT:?>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] , u'<STR_LIT:U+0020>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:2> ] , str ( dt . dt_from_decimal ( raw . when ) ) ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:3> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:4> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:5> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:6> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:7> ] , None ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:8> ] , None ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_request_when_filters ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : REQUEST_ID_1 , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> raw = self . _create_raw ( ) <EOL> results = self . mox . CreateMockAnything ( ) <EOL> when_min = decimal . Decimal ( '<STR_LIT>' ) <EOL> when_max = decimal . Decimal ( '<STR_LIT>' ) <EOL> models . RawData . objects . filter ( request_id = REQUEST_ID_1 , <EOL> when__gte = when_min , <EOL> when__lte = when_max ) . AndReturn ( results ) <EOL> results . order_by ( '<STR_LIT>' ) . AndReturn ( results ) <EOL> results [ None : <NUM_LIT:50> ] . AndReturn ( results ) <EOL> results . __iter__ ( ) . AndReturn ( [ raw ] . __iter__ ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_request ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , [ "<STR_LIT:#>" , "<STR_LIT:?>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] , u'<STR_LIT:U+0020>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:2> ] , str ( dt . dt_from_decimal ( raw . when ) ) ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:3> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:4> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:5> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:6> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:7> ] , None ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:8> ] , None ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_request_bad_request_id ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : "<STR_LIT>" } <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_request ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT> ) <EOL> resp_json = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( resp_json ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( resp_json [ <NUM_LIT:0> ] , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> msg = '<STR_LIT>' <EOL> self . assertEqual ( resp_json [ <NUM_LIT:1> ] , [ '<STR_LIT>' , msg ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def _assert_on_show_nova ( self , json_resp , raw ) : <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:3> ) <EOL> values = json_resp [ <NUM_LIT:0> ] <EOL> self . assertEqual ( len ( values ) , <NUM_LIT:12> ) <EOL> self . assertEqual ( values [ <NUM_LIT:0> ] , [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:1> ] , [ "<STR_LIT:#>" , raw . id ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:2> ] , [ "<STR_LIT>" , <EOL> str ( dt . dt_from_decimal ( raw . when ) ) ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:3> ] , [ "<STR_LIT>" , raw . deployment . name ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:4> ] , [ "<STR_LIT>" , raw . routing_key ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:5> ] , [ "<STR_LIT>" , raw . publisher ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:6> ] , [ "<STR_LIT>" , raw . state ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:7> ] , [ "<STR_LIT>" , raw . event ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:8> ] , [ "<STR_LIT>" , raw . service ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:9> ] , [ "<STR_LIT>" , raw . host ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:10> ] , [ "<STR_LIT>" , raw . instance ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:11> ] , [ "<STR_LIT>" , raw . request_id ] ) <EOL> def _assert_on_show_glance ( self , json_resp , raw ) : <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:3> ) <EOL> values = json_resp [ <NUM_LIT:0> ] <EOL> self . assertEqual ( len ( values ) , <NUM_LIT:12> ) <EOL> self . assertEqual ( values [ <NUM_LIT:0> ] , [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:1> ] , [ "<STR_LIT:#>" , raw . id ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:2> ] , [ "<STR_LIT>" , <EOL> str ( dt . dt_from_decimal ( raw . when ) ) ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:3> ] , [ "<STR_LIT>" , raw . deployment . name ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:4> ] , [ "<STR_LIT>" , raw . routing_key ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:5> ] , [ "<STR_LIT>" , raw . publisher ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:6> ] , [ "<STR_LIT>" , raw . status ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:7> ] , [ "<STR_LIT>" , raw . event ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:8> ] , [ "<STR_LIT>" , raw . service ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:9> ] , [ "<STR_LIT>" , raw . host ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:10> ] , [ "<STR_LIT>" , raw . uuid ] ) <EOL> self . assertEqual ( values [ <NUM_LIT:11> ] , [ "<STR_LIT>" , raw . request_id ] ) <EOL> def test_do_show ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { } <EOL> raw = self . _create_raw ( ) <EOL> models . RawData . objects . get ( id = <NUM_LIT:1> ) . AndReturn ( raw ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_show ( fake_request , <NUM_LIT:1> ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . _assert_on_show_nova ( json_resp , raw ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_show_for_glance_rawdata ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : '<STR_LIT>' } <EOL> raw = self . _create_raw ( ) <EOL> models . GlanceRawData . objects . get ( id = <NUM_LIT:1> ) . AndReturn ( raw ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_show ( fake_request , <NUM_LIT:1> ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . _assert_on_show_glance ( json_resp , raw ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_show_for_generic_rawdata ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : '<STR_LIT>' } <EOL> raw = self . _create_raw ( ) <EOL> models . GenericRawData . objects . get ( id = <NUM_LIT:1> ) . AndReturn ( raw ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_show ( fake_request , <NUM_LIT:1> ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . _assert_on_show_nova ( json_resp , raw ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_show_should_return_empty_result_on_object_not_found_exception ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { } <EOL> raw = self . _create_raw ( ) <EOL> models . RawData . objects . get ( id = <NUM_LIT:1> ) . AndReturn ( raw ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_show ( fake_request , <NUM_LIT:1> ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . _assert_on_show_nova ( json_resp , raw ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_watch_for_glance ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> deployment1 = self . mox . CreateMockAnything ( ) <EOL> deployment1 . id = <NUM_LIT:1> <EOL> deployment1 . name = '<STR_LIT>' <EOL> deployments = [ deployment1 ] <EOL> stacky_server . get_deployments ( ) . AndReturn ( deployments ) <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> events = [ { '<STR_LIT>' : '<STR_LIT>' } , { '<STR_LIT>' : '<STR_LIT>' } ] <EOL> stacky_server . get_event_names ( ) . AndReturn ( events ) <EOL> results = self . mox . CreateMockAnything ( ) <EOL> models . GlanceRawData . objects . order_by ( '<STR_LIT>' ) . AndReturn ( results ) <EOL> results . filter ( when__gt = mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . filter ( when__lte = mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . __iter__ ( ) . AndReturn ( [ self . _create_raw ( ) ] . __iter__ ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_watch ( fake_request , <NUM_LIT:0> ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , [ <NUM_LIT:10> , <NUM_LIT:1> , <NUM_LIT:15> , <NUM_LIT:20> , <NUM_LIT:10> , <NUM_LIT> ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , u'<STR_LIT:U+0020>' ) <EOL> time_str = "<STR_LIT>" % ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] , json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:3> ] ) <EOL> datetime . datetime . strptime ( time_str , "<STR_LIT>" ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:4> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:5> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:6> ] , u'<STR_LIT:%s>' % '<STR_LIT>' ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_watch ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { } <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> deployment1 = self . mox . CreateMockAnything ( ) <EOL> deployment1 . id = <NUM_LIT:1> <EOL> deployment1 . name = '<STR_LIT>' <EOL> deployments = [ deployment1 ] <EOL> stacky_server . get_deployments ( ) . AndReturn ( deployments ) <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> events = [ { '<STR_LIT>' : '<STR_LIT>' } , { '<STR_LIT>' : '<STR_LIT>' } ] <EOL> stacky_server . get_event_names ( ) . AndReturn ( events ) <EOL> results = self . mox . CreateMockAnything ( ) <EOL> model = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> stacky_server . _model_factory ( '<STR_LIT>' ) . AndReturn ( model ) <EOL> model . order_by ( '<STR_LIT>' ) . AndReturn ( results ) <EOL> results . filter ( when__gt = mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . filter ( when__lte = mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . __iter__ ( ) . AndReturn ( [ self . _create_raw ( ) ] . __iter__ ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_watch ( fake_request , <NUM_LIT:0> ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , [ <NUM_LIT:10> , <NUM_LIT:1> , <NUM_LIT:15> , <NUM_LIT:20> , <NUM_LIT:10> , <NUM_LIT> ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , u'<STR_LIT:U+0020>' ) <EOL> time_str = "<STR_LIT>" % ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] , json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:3> ] ) <EOL> datetime . datetime . strptime ( time_str , "<STR_LIT>" ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:4> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:5> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:6> ] , u'<STR_LIT:%s>' % '<STR_LIT>' ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_watch_with_deployment ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : <NUM_LIT:1> } <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> deployment1 = self . mox . CreateMockAnything ( ) <EOL> deployment1 . id = <NUM_LIT:1> <EOL> deployment1 . name = '<STR_LIT>' <EOL> deployments = [ deployment1 ] <EOL> stacky_server . get_deployments ( ) . AndReturn ( deployments ) <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> events = [ { '<STR_LIT>' : '<STR_LIT>' } , { '<STR_LIT>' : '<STR_LIT>' } ] <EOL> stacky_server . get_event_names ( ) . AndReturn ( events ) <EOL> results = self . mox . CreateMockAnything ( ) <EOL> model = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> stacky_server . _model_factory ( '<STR_LIT>' ) . AndReturn ( model ) <EOL> model . order_by ( '<STR_LIT>' ) . AndReturn ( results ) <EOL> results . filter ( deployment = <NUM_LIT:1> ) . AndReturn ( results ) <EOL> results . filter ( when__gt = mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . filter ( when__lte = mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . __iter__ ( ) . AndReturn ( [ self . _create_raw ( ) ] . __iter__ ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_watch ( fake_request , <NUM_LIT:1> ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , [ <NUM_LIT:10> , <NUM_LIT:1> , <NUM_LIT:15> , <NUM_LIT:20> , <NUM_LIT:10> , <NUM_LIT> ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , u'<STR_LIT:U+0020>' ) <EOL> time_str = "<STR_LIT>" % ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] , json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:3> ] ) <EOL> datetime . datetime . strptime ( time_str , "<STR_LIT>" ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:4> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:5> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:6> ] , u'<STR_LIT:%s>' % '<STR_LIT>' ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_watch_with_event_name ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> deployment1 = self . mox . CreateMockAnything ( ) <EOL> deployment1 . id = <NUM_LIT:1> <EOL> deployment1 . name = '<STR_LIT>' <EOL> deployments = [ deployment1 ] <EOL> stacky_server . get_deployments ( ) . AndReturn ( deployments ) <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> events = [ { '<STR_LIT>' : '<STR_LIT>' } , { '<STR_LIT>' : '<STR_LIT>' } ] <EOL> stacky_server . get_event_names ( ) . AndReturn ( events ) <EOL> results = self . mox . CreateMockAnything ( ) <EOL> models . RawData . objects . order_by ( '<STR_LIT>' ) . AndReturn ( results ) <EOL> results . filter ( event = '<STR_LIT>' ) . AndReturn ( results ) <EOL> results . filter ( when__gt = mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . filter ( when__lte = mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . __iter__ ( ) . AndReturn ( [ self . _create_raw ( ) ] . __iter__ ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_watch ( fake_request , <NUM_LIT:0> ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:0> ] , [ <NUM_LIT:10> , <NUM_LIT:1> , <NUM_LIT:15> , <NUM_LIT:20> , <NUM_LIT:10> , <NUM_LIT> ] ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , u'<STR_LIT:U+0020>' ) <EOL> time_str = "<STR_LIT>" % ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] , json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:3> ] ) <EOL> datetime . datetime . strptime ( time_str , "<STR_LIT>" ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:4> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:5> ] , u'<STR_LIT>' ) <EOL> self . assertEqual ( json_resp [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:6> ] , u'<STR_LIT:%s>' % '<STR_LIT>' ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_kpi ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> results = self . mox . CreateMockAnything ( ) <EOL> models . RequestTracker . objects . select_related ( ) . AndReturn ( results ) <EOL> results . exclude ( last_timing = None ) . AndReturn ( results ) <EOL> results . exclude ( start__lt = mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . order_by ( '<STR_LIT>' ) . AndReturn ( results ) <EOL> tracker = self . mox . CreateMockAnything ( ) <EOL> tracker . last_timing = self . mox . CreateMockAnything ( ) <EOL> tracker . last_timing . end_raw = self . mox . CreateMockAnything ( ) <EOL> tracker . last_timing . end_raw . event = '<STR_LIT>' <EOL> deployment = self . mox . CreateMockAnything ( ) <EOL> deployment . name = '<STR_LIT>' <EOL> tracker . last_timing . end_raw . deployment = deployment <EOL> tracker . lifecycle = self . mox . CreateMockAnything ( ) <EOL> tracker . lifecycle . instance = INSTANCE_ID_1 <EOL> tracker . duration = <NUM_LIT:10> <EOL> results . __iter__ ( ) . AndReturn ( [ tracker ] . __iter__ ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_kpi ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> body = resp . content <EOL> body = json . loads ( body ) <EOL> self . assertEqual ( len ( body ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( body [ <NUM_LIT:0> ] , [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> time = u'<STR_LIT:%s>' % stacky_server . sec_to_time ( <NUM_LIT:10> ) <EOL> self . assertEqual ( body [ <NUM_LIT:1> ] , [ u'<STR_LIT:test>' , time , INSTANCE_ID_1 , u'<STR_LIT>' ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_kpi_with_tenant ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> objects = self . mox . CreateMockAnything ( ) <EOL> models . RawData . objects . filter ( tenant = '<STR_LIT>' ) . AndReturn ( objects ) <EOL> objects . count ( ) . AndReturn ( <NUM_LIT:1> ) <EOL> results = self . mox . CreateMockAnything ( ) <EOL> models . RequestTracker . objects . select_related ( ) . AndReturn ( results ) <EOL> results . exclude ( last_timing = None ) . AndReturn ( results ) <EOL> results . exclude ( start__lt = mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . order_by ( '<STR_LIT>' ) . AndReturn ( results ) <EOL> tracker = self . mox . CreateMockAnything ( ) <EOL> tracker . last_timing = self . mox . CreateMockAnything ( ) <EOL> tracker . last_timing . end_raw = self . mox . CreateMockAnything ( ) <EOL> tracker . last_timing . end_raw . event = '<STR_LIT>' <EOL> tracker . last_timing . end_raw . tenant = '<STR_LIT>' <EOL> deployment = self . mox . CreateMockAnything ( ) <EOL> deployment . name = '<STR_LIT>' <EOL> tracker . last_timing . end_raw . deployment = deployment <EOL> tracker . lifecycle = self . mox . CreateMockAnything ( ) <EOL> tracker . lifecycle . instance = INSTANCE_ID_1 <EOL> tracker . duration = <NUM_LIT:10> <EOL> results . __iter__ ( ) . AndReturn ( [ tracker ] . __iter__ ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_kpi ( fake_request , '<STR_LIT>' ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> body = resp . content <EOL> body = json . loads ( body ) <EOL> self . assertEqual ( len ( body ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( body [ <NUM_LIT:0> ] , [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> time = u'<STR_LIT:%s>' % stacky_server . sec_to_time ( <NUM_LIT:10> ) <EOL> self . assertEqual ( body [ <NUM_LIT:1> ] , [ u'<STR_LIT:test>' , time , INSTANCE_ID_1 , u'<STR_LIT>' ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_kpi_with_tenant_no_match ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> objects = self . mox . CreateMockAnything ( ) <EOL> models . RawData . objects . filter ( tenant = '<STR_LIT>' ) . AndReturn ( objects ) <EOL> objects . count ( ) . AndReturn ( <NUM_LIT:1> ) <EOL> results = self . mox . CreateMockAnything ( ) <EOL> models . RequestTracker . objects . select_related ( ) . AndReturn ( results ) <EOL> results . exclude ( last_timing = None ) . AndReturn ( results ) <EOL> results . exclude ( start__lt = mox . IgnoreArg ( ) ) . AndReturn ( results ) <EOL> results . order_by ( '<STR_LIT>' ) . AndReturn ( results ) <EOL> tracker = self . mox . CreateMockAnything ( ) <EOL> tracker . last_timing = self . mox . CreateMockAnything ( ) <EOL> tracker . last_timing . end_raw = self . mox . CreateMockAnything ( ) <EOL> tracker . last_timing . end_raw . event = '<STR_LIT>' <EOL> tracker . last_timing . end_raw . tenant = '<STR_LIT>' <EOL> deployment = self . mox . CreateMockAnything ( ) <EOL> deployment . name = '<STR_LIT>' <EOL> tracker . last_timing . end_raw . deployment = deployment <EOL> tracker . lifecycle = self . mox . CreateMockAnything ( ) <EOL> tracker . lifecycle . instance = INSTANCE_ID_1 <EOL> tracker . duration = <NUM_LIT:10> <EOL> results . __iter__ ( ) . AndReturn ( [ tracker ] . __iter__ ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_kpi ( fake_request , '<STR_LIT>' ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> body = resp . content <EOL> body = json . loads ( body ) <EOL> self . assertEqual ( len ( body ) , <NUM_LIT:1> ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_do_kpi_tenant_doesnt_exist ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> objects = self . mox . CreateMockAnything ( ) <EOL> models . RawData . objects . filter ( tenant = '<STR_LIT>' ) . AndReturn ( objects ) <EOL> objects . count ( ) . AndReturn ( <NUM_LIT:0> ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . do_kpi ( fake_request , '<STR_LIT>' ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT> ) <EOL> body = resp . content <EOL> body = json . loads ( body ) <EOL> self . assertEqual ( len ( body ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( body [ <NUM_LIT:0> ] , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> msg = '<STR_LIT>' <EOL> self . assertEqual ( body [ <NUM_LIT:1> ] , [ '<STR_LIT>' , msg ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_model_factory_for_nova ( self ) : <EOL> self . mox . UnsetStubs ( ) <EOL> nova_model = stacky_server . _model_factory ( '<STR_LIT>' ) <EOL> self . assertEqual ( nova_model . model , models . RawData ) <EOL> def test_model_factory_for_nova ( self ) : <EOL> self . mox . UnsetStubs ( ) <EOL> nova_model = stacky_server . _model_factory ( '<STR_LIT>' ) <EOL> self . assertEqual ( nova_model . model , models . GlanceRawData ) <EOL> def test_model_factory_for_nova ( self ) : <EOL> self . mox . UnsetStubs ( ) <EOL> nova_model = stacky_server . _model_factory ( '<STR_LIT>' ) <EOL> self . assertEqual ( nova_model . model , models . GenericRawData ) <EOL> def _assert_on_search_nova ( self , json_resp , raw ) : <EOL> title = json_resp [ <NUM_LIT:0> ] <EOL> values = json_resp [ <NUM_LIT:1> ] <EOL> self . assertEqual ( len ( values ) , <NUM_LIT:9> ) <EOL> self . assertEqual ( [ title [ <NUM_LIT:0> ] , values [ <NUM_LIT:0> ] ] , [ "<STR_LIT:#>" , raw . id ] ) <EOL> self . assertEqual ( [ title [ <NUM_LIT:1> ] , values [ <NUM_LIT:1> ] ] , [ '<STR_LIT:?>' , '<STR_LIT:U+0020>' ] ) <EOL> self . assertEqual ( [ title [ <NUM_LIT:2> ] , values [ <NUM_LIT:2> ] ] , [ "<STR_LIT>" , <EOL> str ( dt . dt_from_decimal ( raw . when ) ) ] ) <EOL> self . assertEqual ( [ title [ <NUM_LIT:3> ] , values [ <NUM_LIT:3> ] ] , [ "<STR_LIT>" , raw . deployment . name ] ) <EOL> self . assertEqual ( [ title [ <NUM_LIT:4> ] , values [ <NUM_LIT:4> ] ] , [ "<STR_LIT>" , raw . event ] ) <EOL> self . assertEqual ( [ title [ <NUM_LIT:5> ] , values [ <NUM_LIT:5> ] ] , [ "<STR_LIT>" , raw . host ] ) <EOL> self . assertEqual ( [ title [ <NUM_LIT:6> ] , values [ <NUM_LIT:6> ] ] , [ "<STR_LIT>" , raw . state ] ) <EOL> self . assertEqual ( [ title [ <NUM_LIT:7> ] , values [ <NUM_LIT:7> ] ] , [ "<STR_LIT>" , raw . old_state ] ) <EOL> def test_search_by_field_for_nova ( self ) : <EOL> search_result = [ [ "<STR_LIT:#>" , "<STR_LIT:?>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , [ <NUM_LIT:1> , "<STR_LIT:U+0020>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , None , None ] ] <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:value>' : '<STR_LIT>' } <EOL> raw = self . _create_raw ( ) <EOL> results = self . mox . CreateMockAnything ( ) <EOL> models . RawData . objects . filter ( tenant = '<STR_LIT>' ) . AndReturn ( results ) <EOL> results . order_by ( '<STR_LIT>' ) . AndReturn ( [ raw ] ) <EOL> raw . search_results ( [ ] , mox . IgnoreArg ( ) , '<STR_LIT:U+0020>' ) . AndReturn ( search_result ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . search ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . _assert_on_search_nova ( json_resp , raw ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_search_by_field_for_nova_when_filters ( self ) : <EOL> search_result = [ [ "<STR_LIT:#>" , "<STR_LIT:?>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , [ <NUM_LIT:1> , "<STR_LIT:U+0020>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , None , None ] ] <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:value>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> raw = self . _create_raw ( ) <EOL> results = self . mox . CreateMockAnything ( ) <EOL> models . RawData . objects . filter ( tenant = '<STR_LIT>' , <EOL> when__gte = decimal . Decimal ( '<STR_LIT>' ) , <EOL> when__lte = decimal . Decimal ( '<STR_LIT>' ) ) . AndReturn ( results ) <EOL> results . order_by ( '<STR_LIT>' ) . AndReturn ( [ raw ] ) <EOL> raw . search_results ( [ ] , mox . IgnoreArg ( ) , '<STR_LIT:U+0020>' ) . AndReturn ( search_result ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . search ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . _assert_on_search_nova ( json_resp , raw ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_search_by_field_for_nova_with_limit ( self ) : <EOL> search_result = [ [ "<STR_LIT:#>" , "<STR_LIT:?>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , [ <NUM_LIT:1> , "<STR_LIT:U+0020>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , None , None ] ] <EOL> search_result_2 = [ [ "<STR_LIT:#>" , "<STR_LIT:?>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , [ <NUM_LIT:1> , "<STR_LIT:U+0020>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , None , None ] , [ <NUM_LIT:2> , "<STR_LIT:U+0020>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , None , None ] ] <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:value>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> raw1 = self . _create_raw ( ) <EOL> raw2 = self . _create_raw ( ) <EOL> raw3 = self . _create_raw ( ) <EOL> raw2 . id = <NUM_LIT:2> <EOL> raw3 . id = <NUM_LIT:3> <EOL> results = self . mox . CreateMockAnything ( ) <EOL> models . RawData . objects . filter ( tenant = '<STR_LIT>' ) . AndReturn ( results ) <EOL> results . order_by ( '<STR_LIT>' ) . AndReturn ( [ raw1 , raw2 , raw3 ] ) <EOL> raw1 . search_results ( [ ] , mox . IgnoreArg ( ) , '<STR_LIT:U+0020>' ) . AndReturn ( search_result ) <EOL> raw2 . search_results ( search_result , mox . IgnoreArg ( ) , '<STR_LIT:U+0020>' ) . AndReturn ( search_result_2 ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . search ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEqual ( len ( json_resp ) , <NUM_LIT:3> ) <EOL> self . _assert_on_search_nova ( json_resp , raw1 ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_search_with_wrong_field_value_returns_400_error_and_a_message ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:value>' : '<STR_LIT>' } <EOL> models . RawData . objects . filter ( tenant = '<STR_LIT>' ) . AndRaise ( FieldError ) <EOL> self . mox . ReplayAll ( ) <EOL> resp = stacky_server . search ( fake_request ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT> ) <EOL> json_resp = json . loads ( resp . content ) <EOL> self . assertEquals ( json_resp [ <NUM_LIT:0> ] , [ u'<STR_LIT>' , u'<STR_LIT>' ] ) <EOL> self . assertEquals ( json_resp [ <NUM_LIT:1> ] , <EOL> [ u'<STR_LIT>' , u"<STR_LIT>" <EOL> u"<STR_LIT>" <EOL> u"<STR_LIT>" ] ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_model_search_default_limit ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { } <EOL> fake_model = self . mox . CreateMockAnything ( ) <EOL> filters = { '<STR_LIT>' : '<STR_LIT:value>' } <EOL> results = self . mox . CreateMockAnything ( ) <EOL> fake_model . filter ( ** filters ) . AndReturn ( results ) <EOL> results [ None : <NUM_LIT:50> ] . AndReturn ( results ) <EOL> self . mox . ReplayAll ( ) <EOL> actual_results = stacky_server . model_search ( fake_request , fake_model , <EOL> filters ) <EOL> self . assertEqual ( actual_results , results ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_model_search_default_limit_with_offset ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : '<STR_LIT:1>' } <EOL> fake_model = self . mox . CreateMockAnything ( ) <EOL> filters = { '<STR_LIT>' : '<STR_LIT:value>' } <EOL> results = self . mox . CreateMockAnything ( ) <EOL> fake_model . filter ( ** filters ) . AndReturn ( results ) <EOL> results [ <NUM_LIT:1> : <NUM_LIT> ] . AndReturn ( results ) <EOL> self . mox . ReplayAll ( ) <EOL> actual_results = stacky_server . model_search ( fake_request , fake_model , <EOL> filters ) <EOL> self . assertEqual ( actual_results , results ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_model_search_default_with_limit ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : '<STR_LIT:1>' } <EOL> fake_model = self . mox . CreateMockAnything ( ) <EOL> filters = { '<STR_LIT>' : '<STR_LIT:value>' } <EOL> results = self . mox . CreateMockAnything ( ) <EOL> fake_model . filter ( ** filters ) . AndReturn ( results ) <EOL> results [ None : <NUM_LIT:1> ] . AndReturn ( results ) <EOL> self . mox . ReplayAll ( ) <EOL> actual_results = stacky_server . model_search ( fake_request , fake_model , <EOL> filters ) <EOL> self . assertEqual ( actual_results , results ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_model_search_default_with_limit_and_offset ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { '<STR_LIT>' : '<STR_LIT:5>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> fake_model = self . mox . CreateMockAnything ( ) <EOL> filters = { '<STR_LIT>' : '<STR_LIT:value>' } <EOL> results = self . mox . CreateMockAnything ( ) <EOL> fake_model . filter ( ** filters ) . AndReturn ( results ) <EOL> results [ <NUM_LIT:10> : <NUM_LIT:15> ] . AndReturn ( results ) <EOL> self . mox . ReplayAll ( ) <EOL> actual_results = stacky_server . model_search ( fake_request , fake_model , <EOL> filters ) <EOL> self . assertEqual ( actual_results , results ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_model_search_related ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { } <EOL> fake_model = self . mox . CreateMockAnything ( ) <EOL> filters = { '<STR_LIT>' : '<STR_LIT:value>' } <EOL> results = self . mox . CreateMockAnything ( ) <EOL> fake_model . select_related ( ) . AndReturn ( results ) <EOL> results . filter ( ** filters ) . AndReturn ( results ) <EOL> results [ None : <NUM_LIT:50> ] . AndReturn ( results ) <EOL> self . mox . ReplayAll ( ) <EOL> actual_results = stacky_server . model_search ( fake_request , fake_model , <EOL> filters , related = True ) <EOL> self . assertEqual ( actual_results , results ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_model_order_by ( self ) : <EOL> fake_request = self . mox . CreateMockAnything ( ) <EOL> fake_request . GET = { } <EOL> fake_model = self . mox . CreateMockAnything ( ) <EOL> filters = { '<STR_LIT>' : '<STR_LIT:value>' } <EOL> results = self . mox . CreateMockAnything ( ) <EOL> fake_model . filter ( ** filters ) . AndReturn ( results ) <EOL> results . order_by ( '<STR_LIT>' ) . AndReturn ( results ) <EOL> results [ None : <NUM_LIT:50> ] . AndReturn ( results ) <EOL> self . mox . ReplayAll ( ) <EOL> actual_results = stacky_server . model_search ( fake_request , fake_model , <EOL> filters , order_by = '<STR_LIT>' ) <EOL> self . assertEqual ( actual_results , results ) <EOL> self . mox . VerifyAll ( ) <EOL> class JsonReportsSearchAPI ( StacktachBaseTestCase ) : <EOL> def setUp ( self ) : <EOL> self . mox = mox . Mox ( ) <EOL> self . model = models . JsonReport . objects <EOL> self . model_search_result = self . mox . CreateMockAnything ( ) <EOL> self . model_search_result . id = '<STR_LIT>' <EOL> self . model_search_result . period_start = datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> , ) <EOL> self . model_search_result . period_end = datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> ) <EOL> self . model_search_result . created = <NUM_LIT> <EOL> self . model_search_result . name = '<STR_LIT>' <EOL> self . model_search_result . version = <NUM_LIT:4> <EOL> def tearDown ( self ) : <EOL> self . mox . UnsetStubs ( ) <EOL> def test_jsonreports_search_order_by_id ( self ) : <EOL> request = self . mox . CreateMockAnything ( ) <EOL> request . GET = { <EOL> '<STR_LIT:id>' : <NUM_LIT:1> , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> filters = { <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : decimal . Decimal ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : decimal . Decimal ( '<STR_LIT>' ) , <EOL> } <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> stacky_server . model_search ( request , self . model , filters , <EOL> order_by = '<STR_LIT>' ) . AndReturn ( <EOL> [ self . model_search_result ] ) <EOL> self . mox . ReplayAll ( ) <EOL> actual_result = stacky_server . do_jsonreports_search ( request ) . content <EOL> expected_result = [ <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:Name>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:4> ] <EOL> ] <EOL> self . assertEquals ( ast . literal_eval ( actual_result ) , expected_result ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_jsonreports_search_with_limit_offset ( self ) : <EOL> request = self . mox . CreateMockAnything ( ) <EOL> request . GET = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:10> , <EOL> '<STR_LIT>' : <NUM_LIT:5> <EOL> } <EOL> filters = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> self . mox . StubOutWithMock ( stacky_server , '<STR_LIT>' ) <EOL> stacky_server . model_search ( request , self . model , filters , <EOL> order_by = '<STR_LIT>' ) . AndReturn ( <EOL> [ self . model_search_result ] ) <EOL> self . mox . ReplayAll ( ) <EOL> actual_result = stacky_server . do_jsonreports_search ( request ) . content <EOL> expected_result = [ [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:Name>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:4> ] ] <EOL> self . assertEquals ( ast . literal_eval ( actual_result ) , expected_result ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_jsonreports_search_with_invalid_fields ( self ) : <EOL> request = self . mox . CreateMockAnything ( ) <EOL> request . GET = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:version>' : <NUM_LIT:4> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> self . mox . ReplayAll ( ) <EOL> actual_result = stacky_server . do_jsonreports_search ( request ) . content <EOL> expected_result = [ <EOL> [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" , "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ] <EOL> ] <EOL> self . assertEqual ( ast . literal_eval ( actual_result ) , expected_result ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_jsonreports_search_with_invalid_period_start ( self ) : <EOL> request = self . mox . CreateMockAnything ( ) <EOL> request . GET = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . mox . ReplayAll ( ) <EOL> actual_result = stacky_server . do_jsonreports_search ( request ) . content <EOL> expected_result = [ <EOL> [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" , "<STR_LIT>" <EOL> "<STR_LIT>" ] <EOL> ] <EOL> self . assertEqual ( ast . literal_eval ( actual_result ) , expected_result ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_jsonreports_search_with_invalid_period_end ( self ) : <EOL> request = self . mox . CreateMockAnything ( ) <EOL> request . GET = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . mox . ReplayAll ( ) <EOL> actual_result = stacky_server . do_jsonreports_search ( request ) . content <EOL> expected_result = [ <EOL> [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" , "<STR_LIT>" <EOL> "<STR_LIT>" ] <EOL> ] <EOL> self . assertEqual ( ast . literal_eval ( actual_result ) , expected_result ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_jsonreports_search_with_invalid_id ( self ) : <EOL> request = self . mox . CreateMockAnything ( ) <EOL> request . GET = { '<STR_LIT:id>' : '<STR_LIT>' } <EOL> self . mox . ReplayAll ( ) <EOL> actual_result = stacky_server . do_jsonreports_search ( request ) . content <EOL> expected_result = [ <EOL> [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" , "<STR_LIT>" <EOL> "<STR_LIT>" ] <EOL> ] <EOL> self . assertEqual ( ast . literal_eval ( actual_result ) , expected_result ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_jsonreports_search_with_invalid_created_format ( self ) : <EOL> request = self . mox . CreateMockAnything ( ) <EOL> request . GET = { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> self . mox . ReplayAll ( ) <EOL> actual_result = stacky_server . do_jsonreports_search ( request ) . content <EOL> expected_result = [ <EOL> [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" , "<STR_LIT>" <EOL> "<STR_LIT>" ] <EOL> ] <EOL> self . assertEqual ( ast . literal_eval ( actual_result ) , expected_result ) <EOL> self . mox . VerifyAll ( ) <EOL> def test_jsonreports_search_by_invalid_created_400 ( self ) : <EOL> request = self . mox . CreateMockAnything ( ) <EOL> request . GET = { <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> self . mox . ReplayAll ( ) <EOL> actual_result = stacky_server . do_jsonreports_search ( request ) . content <EOL> expected_result = [ <EOL> [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" , "<STR_LIT>" <EOL> "<STR_LIT>" ] <EOL> ] <EOL> self . assertEquals ( ast . literal_eval ( actual_result ) , expected_result ) <EOL> self . mox . VerifyAll ( ) </s>
