def setup_method(self, method): self.ext = External() self.mox = mox.Mox() self.envfilename = 'test.env'
def setUp(self): self.mox = mox.Mox() self.mox.StubOutWithMock(metrics._MetricsLogger, 'LogOnceOnStop')
def setUp(self): self.mox = mox.Mox() self.maxDiff = None
def setUp(self): super(BaseTestCase, self).setUp() self.m = mox.Mox() self.addCleanup(self.m.UnsetStubs) self.useFixture(fixtures.FakeLogger())
def setUp(self): RPCMapperTestBase.setUp(self) webapp_test_util.RequestHandlerTestBase.setUp(self) self.mox = mox.Mox() self.protocol = self.mox.CreateMockAnything()
def setUp(self): """Run before each test method to initialize test environment.""" super(TestCase, self).setUp() test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0) try: test_timeout = int(test_timeout) except ValueError: # If timeout value is invalid do not set a timeout. test_timeout = 0 if test_timeout > 0: self.useFixture(fixtures.Timeout(test_timeout, gentle=True)) self.useFixture(fixtures.NestedTempfile()) self.useFixture(fixtures.TempHomeDir()) environ_enabled = (lambda var_name: strutils.bool_from_string( os.environ.get(var_name))) if environ_enabled('OS_STDOUT_CAPTURE'): stdout = self.useFixture(fixtures.StringStream('stdout')).stream self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout)) if environ_enabled('OS_STDERR_CAPTURE'): stderr = self.useFixture(fixtures.StringStream('stderr')).stream self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr)) if environ_enabled('OS_LOG_CAPTURE'): log_format = '%(levelname)s [%(name)s] %(message)s' if environ_enabled('OS_DEBUG'): level = logging.DEBUG else: level = logging.INFO self.useFixture( fixtures.LoggerFixture(nuke_handlers=False, format=log_format, level=level)) rpc.add_extra_exmods("cinder.tests") self.addCleanup(rpc.clear_extra_exmods) self.addCleanup(rpc.cleanup) self.messaging_conf = messaging_conffixture.ConfFixture(CONF) self.messaging_conf.transport_driver = 'fake' self.messaging_conf.response_timeout = 15 self.useFixture(self.messaging_conf) rpc.init(CONF) conf_fixture.set_defaults(CONF) CONF([], default_config_files=[]) # NOTE(vish): We need a better method for creating fixtures for tests # now that we have some required db setup for the system # to work properly. self.start = timeutils.utcnow() CONF.set_default('connection', 'sqlite://', 'database') CONF.set_default('sqlite_synchronous', False, 'database') global _DB_CACHE if not _DB_CACHE: _DB_CACHE = Database(sqla_api, migration, sql_connection=CONF.database.connection, sqlite_db=CONF.database.sqlite_db, sqlite_clean_db=CONF.sqlite_clean_db) self.useFixture(_DB_CACHE) # emulate some of the mox stuff, we can't use the metaclass # because it screws with our generators self.mox = mox.Mox() self.stubs = stubout.StubOutForTesting() self.addCleanup(CONF.reset) self.addCleanup(self.mox.UnsetStubs) self.addCleanup(self.stubs.UnsetAll) self.addCleanup(self.stubs.SmartUnsetAll) self.addCleanup(self.mox.VerifyAll) self.addCleanup(self._common_cleanup) self.injected = [] self._services = [] fake_notifier.stub_notifier(self.stubs) self.override_config('fatal_exception_format_errors', True) # This will be cleaned up by the NestedTempfile fixture lock_path = self.useFixture(fixtures.TempDir()).path self.fixture = self.useFixture(config_fixture.Config(lockutils.CONF)) self.fixture.config(lock_path=lock_path, group='oslo_concurrency') self.override_config( 'policy_file', os.path.join( os.path.abspath(os.path.join( os.path.dirname(__file__), '..', )), 'cinder/tests/policy.json'))
def setUp(self): self.mox = mox.Mox() self.mox.StubOutWithMock(imp, 'find_module') self.mox.StubOutWithMock(stubs.FakeFile, 'is_file_accessible') self.hook = sandbox.PathRestrictingImportHook([re.compile(r'lxml(\..*)?$')])
def setUp(self): self.mox = mox.Mox() self.naming = self.mox.CreateMock(naming.Naming)
def setUp(self): self.m = mox.Mox() self.fc = fakes.FakeClient() self.path = os.path.dirname(os.path.realpath(__file__)).\ replace('heat/tests', 'templates')
def setUp(self): super(TremaIdConvertTest, self).setUp() self.driver = drivers.get_driver(self.driver_name)(TestConfig) self.mox = mox.Mox() self.ctx = self.mox.CreateMock(context.Context) self.addCleanup(self.mox.UnsetStubs)
def setUp(self): super(TremaDriverTestBase, self).setUp() self.mox = mox.Mox() self.driver = drivers.get_driver(self.driver_name)(TestConfig) self.mox.StubOutWithMock(ofc_client.OFCClient, 'do_request') self.addCleanup(self.mox.UnsetStubs)
def setUp(self): self.m = mox.Mox() self.m.StubOutWithMock(stack.Stack, 'create_with_template') self.m.StubOutWithMock(dbi.DBInstance, 'nested')
def setUp(self): self.m = mox.Mox() self.fc = fakes.FakeKeystoneClient(username='******') cfg.CONF.set_default('heat_stack_user_role', 'stack_user_role')
def setUp(self): super(TestUtils, self).setUp() self._mox = mox.Mox() self.addCleanup(self._mox.UnsetStubs)
def test_set_cookie_prevents_caching(self): """Tests that the Set-Cookie header prevents caching from taking place.""" # Test with no explicit Cache-Control and Expires headers. m = mox.Mox() m.StubOutWithMock(time, 'time') time.time().AndReturn(788918400) # 1 Jan 1995 00:00:00 m.ReplayAll() application = wsgi_test_utils.constant_app( '200 OK', [('Content-Type', 'text/html'), ('Set-Cookie', 'UserID=john; Max-Age=3600; Version=1'), ], 'this is my data') expected_status = '200 OK' expected_headers = { 'Content-Type': 'text/html', 'Cache-Control': 'no-cache', 'Expires': 'Fri, 01 Jan 1990 00:00:00 GMT', 'Content-length': '15', 'Set-Cookie': 'UserID=john; Max-Age=3600; Version=1', } expected_body = 'this is my data' self.assert_rewritten_response(expected_status, expected_headers, expected_body, application) m.VerifyAll() m.UnsetStubs() # Test with explicit Cache-Control: public and future Expires headers. m = mox.Mox() m.StubOutWithMock(time, 'time') time.time().AndReturn(788918400) # 1 Jan 1995 00:00:00 m.ReplayAll() application = wsgi_test_utils.constant_app( '200 OK', [('Content-Type', 'text/html'), ('Cache-Control', 'public'), ('Cache-Control', 'max-age=20'), ('Expires', 'Mon, 25 Jul 9999 14:47:05 GMT'), ('Set-Cookie', 'UserID=john; Max-Age=3600; Version=1'), ], 'this is my data') expected_status = '200 OK' expected_headers = { 'Content-Type': 'text/html', 'Cache-Control': 'max-age=20, private', 'Expires': 'Sun, 01 Jan 1995 00:00:00 GMT', 'Content-Length': '15', 'Set-Cookie': 'UserID=john; Max-Age=3600; Version=1', } expected_body = 'this is my data' self.assert_rewritten_response(expected_status, expected_headers, expected_body, application) m.VerifyAll() m.UnsetStubs() # Test with explicit Cache-Control: private and past Expires headers. m = mox.Mox() m.StubOutWithMock(time, 'time') time.time().AndReturn(788918400) # 1 Jan 1995 00:00:00 m.ReplayAll() application = wsgi_test_utils.constant_app( '200 OK', [('Content-Type', 'text/html'), ('Cache-Control', 'private, max-age=20'), ('Expires', 'Mon, 13 Mar 1992 18:12:51 GMT'), ('Set-Cookie', 'UserID=john; Max-Age=3600; Version=1'), ], 'this is my data') expected_status = '200 OK' expected_headers = { 'Content-Type': 'text/html', 'Cache-Control': 'private, max-age=20', 'Expires': 'Mon, 13 Mar 1992 18:12:51 GMT', 'Content-Length': '15', 'Set-Cookie': 'UserID=john; Max-Age=3600; Version=1', } expected_body = 'this is my data' self.assert_rewritten_response(expected_status, expected_headers, expected_body, application) m.VerifyAll() m.UnsetStubs() # Test with a non-cacheable status code. # Note: For simplicity, we simply treat this as normal (unlike production, # which does not sanitize such cases). m = mox.Mox() m.StubOutWithMock(time, 'time') time.time().AndReturn(788918400) # 1 Jan 1995 00:00:00 m.ReplayAll() application = wsgi_test_utils.constant_app( '404 Not Found', [('Content-Type', 'text/html'), ('Cache-Control', 'public, max-age=20'), ('Expires', 'Mon, 25 Jul 9999 14:47:05 GMT'), ('Set-Cookie', 'UserID=john; Max-Age=3600; Version=1'), ], 'this is my data') expected_status = '404 Not Found' expected_headers = { 'Content-Type': 'text/html', 'Cache-Control': 'max-age=20, private', 'Expires': 'Sun, 01 Jan 1995 00:00:00 GMT', 'Content-Length': '15', 'Set-Cookie': 'UserID=john; Max-Age=3600; Version=1', } expected_body = 'this is my data' self.assert_rewritten_response(expected_status, expected_headers, expected_body, application) m.VerifyAll() m.UnsetStubs()
def setUp(self): self.mox = mox.Mox() self.encoder = encoder.Encoder() self.mock_stream = self.mox.CreateMock(output_stream.OutputStream) self.mock_message = self.mox.CreateMock(message.Message) self.encoder._stream = self.mock_stream
def setUp(self): self.cache = TestCache() self._saved_environ = os.environ.copy() if 'AUTH_DOMAIN' not in os.environ: os.environ['AUTH_DOMAIN'] = 'gmail.com' self.mox = mox.Mox()
def setUp(self): self.mox = mox.Mox() pass
def setUp(self): super(CoreStorageTest, self).setUp() self.mox = mox.Mox()
def setUp(self): self.mox = mox.Mox() self.enumerator = self.mox.CreateMockAnything() self.constructor = self.mox.CreateMockAnything() self.dict = hyou.util.LazyOrderedDictionary( enumerator=self.enumerator, constructor=self.constructor)
def setUp(self): self.mox = mox.Mox() self.mock_stream = self.mox.CreateMock(input_stream.InputStream) self.mock_message = self.mox.CreateMock(message.Message)
def setUp(self): self._mox = mox.Mox() # Ensure we start in a clean state. _mkdtemp_unregister_cleaner()
def setUp(self): self.mox = mox.Mox() self.transport = self.mox.CreateMockAnything()
def setUp(self): super(UnauthenticatedTestCase, self).setUp() self.mox = mox.Mox() self._original_time = time.time time.time = lambda: 1234 requests.request = self.mox.CreateMockAnything()
def setUp(self): self.mox = mox.Mox() self.mox.StubOutWithMock(application_configuration.ModuleConfiguration, '_parse_configuration') self.mox.StubOutWithMock(os.path, 'getmtime')
def setUp(self): super(RemoteFsDriverTestCase, self).setUp() self._driver = nfs.RemoteFsDriver() self._mox = mox_lib.Mox() self.addCleanup(self._mox.UnsetStubs)
def setUp(self): self.m = mox.Mox()
def setUp(self): super(BitLockerAdSyncTest, self).setUp() self.mox = mox.Mox() self.mock_client = self.mox.CreateMockAnything() self.c = bitlocker_ad_sync.BitLockerAdSync(client=self.mock_client) bitlocker_ad_sync.FLAGS.redact_recovery_passwords = False
def setUp(self): self.mox = mox.Mox() self.server = wsgi_server.WsgiServer(('localhost', 123), None)
def __init__(self, test_case_name): self._mox = mox.Mox() super(HyperVAPITestCase, self).__init__(test_case_name)