<s> from django . test import TestCase <EOL> from mock import NonCallableMock <EOL> from silk . collector import DataCollector <EOL> from silk . middleware import SilkyMiddleware <EOL> from . util import delete_all_models <EOL> from silk . config import SilkyConfig <EOL> from silk . models import Request <EOL> class TestConfigMeta ( TestCase ) : <EOL> def _mock_response ( self ) : <EOL> response = NonCallableMock ( ) <EOL> response . _headers = { } <EOL> response . status_code = <NUM_LIT:200> <EOL> response . queries = [ ] <EOL> response . get = response . _headers . get <EOL> response . content = '<STR_LIT>' <EOL> return response <EOL> def _execute_request ( self ) : <EOL> delete_all_models ( Request ) <EOL> DataCollector ( ) . configure ( Request . objects . create ( ) ) <EOL> response = self . _mock_response ( ) <EOL> SilkyMiddleware ( ) . _process_response ( '<STR_LIT>' , response ) <EOL> self . assertTrue ( response . status_code == <NUM_LIT:200> ) <EOL> objs = Request . objects . all ( ) <EOL> self . assertEqual ( objs . count ( ) , <NUM_LIT:1> ) <EOL> r = objs [ <NUM_LIT:0> ] <EOL> return r <EOL> def test_enabled ( self ) : <EOL> SilkyConfig ( ) . SILKY_META = True <EOL> r = self . _execute_request ( ) <EOL> self . assertTrue ( r . meta_time is not None or <EOL> r . meta_num_queries is not None or <EOL> r . meta_time_spent_queries is not None ) <EOL> def test_disabled ( self ) : <EOL> SilkyConfig ( ) . SILKY_META = False <EOL> r = self . _execute_request ( ) <EOL> self . assertFalse ( r . meta_time ) </s>
