Beispiel #1
0
 def setUp(self):
     super(NotifierTestCase, self).setUp()
     self.stubs = stubout.StubOutForTesting()
Beispiel #2
0
    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())

        if (os.environ.get('OS_STDOUT_CAPTURE') == 'True' or
                os.environ.get('OS_STDOUT_CAPTURE') == '1'):
            stdout = self.useFixture(fixtures.StringStream('stdout')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
        if (os.environ.get('OS_STDERR_CAPTURE') == 'True' or
                os.environ.get('OS_STDERR_CAPTURE') == '1'):
            stderr = self.useFixture(fixtures.StringStream('stderr')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))

        self.log_fixture = self.useFixture(fixtures.FakeLogger())

        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)

        self.log_fixture = self.useFixture(fixtures.FakeLogger())

        global _DB_CACHE
        if not _DB_CACHE:
            _DB_CACHE = Database(session, migration,
                                 sql_connection=CONF.database.connection,
                                 sqlite_db=CONF.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.injected = []
        self._services = []

        CONF.set_override('fatal_exception_format_errors', True)
        # This will be cleaned up by the NestedTempfile fixture
        CONF.set_override('lock_path', tempfile.mkdtemp())
Beispiel #3
0
 def setUp(self):
     super(MachineDataTest, self).setUp()
     self.mox = mox.Mox()
     self.md = machine_data._MachineData({})
     self.stubs = stubout.StubOutForTesting()
Beispiel #4
0
 def setUp(self):
     super(TestKeystoneAuthPlugin, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     self.addCleanup(self.stubs.UnsetAll)
Beispiel #5
0
 def setUp(self):
     mox.MoxTestBase.setUp(self)
     self.stubs = stubout.StubOutForTesting()
     self.settings = self._GetTestSettings()
Beispiel #6
0
  def __init__(self):
    """Initialize a new Mox."""

    self._mock_objects = []
    self.stubs = stubout.StubOutForTesting()
Beispiel #7
0
 def setUp(self):
     mox.MoxTestBase.setUp(self)
     self.stubs = stubout.StubOutForTesting()
     self.munki = plist.MunkiManifestPlist()
Beispiel #8
0
 def setUp(self):
     mox.MoxTestBase.setUp(self)
     self.stubs = stubout.StubOutForTesting()
     self.dt = util.Datetime
 def setUp(self):
     """Run once for each test in the class."""
     self.mox = mox.Mox()
     self.stubs = stubout.StubOutForTesting()
Beispiel #10
0
 def setUp(self):
     mox.MoxTestBase.setUp(self)
     self.stubs = stubout.StubOutForTesting()
     self.cls = models.KeyValueCache
     self.key = 'example_ip_blocks'
Beispiel #11
0
 def setUp(self):
     """Establish a clean test environment"""
     self.stubs = stubout.StubOutForTesting()
     stub_out_s3(self.stubs)
     self.store = Store(S3_OPTIONS)
Beispiel #12
0
 def setUp(self):
     mox.MoxTestBase.setUp(self)
     self.stubs = stubout.StubOutForTesting()
     self.bdo = x509.BaseDataObject()
Beispiel #13
0
 def setUp(self):
     self.stubs = stubout.StubOutForTesting()
     self.stubs.Set(docker, 'Client', FakeDockerClient)
     reset()
Beispiel #14
0
 def setUp(self):
     super(CallZoneMethodTest, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     self.stubs.Set(db, 'zone_get_all', zone_get_all)
     self.stubs.Set(novaclient, 'Client', FakeNovaClientZones)
Beispiel #15
0
 def setUp(self):
     test.AppengineTest.setUp(self)
     mox.MoxTestBase.setUp(self)
     self.stubs = stubout.StubOutForTesting()
 def setUp(self):
     super(FixedIpCommandsTestCase, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     db_fakes.stub_out_db_network_api(self.stubs)
     self.commands = engine_manage.FixedIpCommands()
Beispiel #17
0
    def setUp(self):
        """Run before each test method to initialize test environment."""
        super(TestCase, self).setUp()

        # Unit tests do not need to use lazy gettext
        i18n.enable_lazy(False)

        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')
        lockutils.set_defaults(lock_path)
        self.override_config('policy_file',
                             os.path.join(
                                 os.path.abspath(
                                     os.path.join(
                                         os.path.dirname(__file__),
                                         '..',
                                     )
                                 ),
                                 'cinder/tests/policy.json'))
Beispiel #18
0
 def setUp(self):
     mox.MoxTestBase.setUp(self)
     self.stubs = stubout.StubOutForTesting()
     self.apc = client.AuthSimianClient()
Beispiel #19
0
 def setUp(self):
     mox.MoxTestBase.setUp(self)
     self.stubs = stubout.StubOutForTesting()
     self.apl = plist.ApplePlist()
Beispiel #20
0
 def setUp(self):
   mox.MoxTestBase.setUp(self)
   self.stubs = stubout.StubOutForTesting()
   self.g = group_sync.GroupSync()
Beispiel #21
0
 def setUp(self):
     mox.MoxTestBase.setUp(self)
     self.stubs = stubout.StubOutForTesting()
     self.munki = plist.MunkiPackageInfoPlist()
Beispiel #22
0
 def setUp(self):
     """Establish a clean test environment"""
     self.stubs = stubout.StubOutForTesting()
     stub_out_s3(self.stubs)
     self.store = Store(test_utils.TestConfigOpts(S3_CONF))
Beispiel #23
0
 def setUp(self):
     super(EngineRpcAPITestCase, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     self.identity = dict(
         identifier.HeatIdentifier('engine_test_tenant', '6', 'wordpress'))
     self.rpcapi = rpc_client.EngineClient()
Beispiel #24
0
 def setUp(self):
     self.stubs = stubout.StubOutForTesting()
Beispiel #25
0
 def setUp(self):
     """Run before each test method to initialize test environment."""
     super(TestCase, self).setUp()
     self.stubs = stubout.StubOutForTesting()
Beispiel #26
0
 def setUp(self):
     self.stubs = stubout.StubOutForTesting()
     stub_out_http_backend(self.stubs)
     Store.CHUNKSIZE = 2
     self.store = Store({})
Beispiel #27
0
 def setUp(self):
     self.stubs = stubout.StubOutForTesting()
     super(RequestTest, self).setUp()
Beispiel #28
0
 def setUp(self):
     mox.MoxTestBase.setUp(self)
     self.stubs = stubout.StubOutForTesting()
     self.dfd = applesus.DistFileDocument()
Beispiel #29
0
 def setUp(self):
     mox.MoxTestBase.setUp(self)
     self.stubs = stubout.StubOutForTesting()
Beispiel #30
0
 def setUp(self):
     super(BaseTestCase, self).setUp()
     self.mox = mox.Mox()
     self.stubs = stubout.StubOutForTesting()
     self._overridden_opts = []