Exemple #1
0
def main():
    sys.path = extra_paths + sys.path
    os.environ['SERVER_SOFTWARE'] = 'Development via nose'
    os.environ['SERVER_NAME'] = 'Foo'
    os.environ['SERVER_PORT'] = '8080'
    os.environ['APPLICATION_ID'] = 'test-app-run'
    os.environ['USER_EMAIL'] = '*****@*****.**'
    os.environ['USER_ID'] = '42'
    os.environ['CURRENT_VERSION_ID'] = 'testing-version'
    os.environ['HTTP_HOST'] = 'some.testing.host.tld'
    setup_gae_services()

    import main as app_main
    import django.test.utils
    django.test.utils.setup_test_environment()

    plugins = [AppEngineDatastoreClearPlugin()]
    # For coverage
    if '--coverage' in sys.argv:
        from nose.plugins import cover
        plugin = cover.Coverage()
        from mox import stubout
        stubout_obj = stubout.StubOutForTesting()
        stubout_obj.SmartSet(plugin, 'begin', begin)
        plugins.append(plugin)

        args = [
            '--with-coverage', '--cover-package=soc.', '--cover-erase',
            '--cover-html', '--cover-html-dir=coverageResults'
        ]

        sys.argv.remove('--coverage')
        sys.argv += args
    else:
        load_melange()

    # For multiprocess
    will_multiprocess = False
    for arg in sys.argv[1:]:
        if '--processes' in arg:
            will_multiprocess = True
            break
    if will_multiprocess:
        from mox import stubout
        from nose.plugins import multiprocess
        stubout_obj = stubout.StubOutForTesting()
        stubout_obj.SmartSet(multiprocess, '__runner', multiprocess_runner)
        # The default --process-timeout (10s) is too short
        sys.argv += ['--process-timeout=300']

    # Ignore functional and old_app tests
    args = ['--exclude=functional', '--exclude=^old_app$']
    sys.argv += args
    nose.main(addplugins=plugins)
Exemple #2
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()
Exemple #3
0
 def setUp(self):
     self._mox = mox_lib.Mox()
     self.stubs = stubout.StubOutForTesting()
     self.configuration = mox_lib.MockObject(conf.Configuration)
     self.configuration.append_config_values(mox_lib.IgnoreArg())
     self.configuration.nfs_shares_config = None
     self.configuration.nfs_mount_point_base = '$state_path/mnt'
     self.configuration.nfs_disk_util = 'df'
     self.configuration.nfs_sparsed_volumes = True
     self._driver = nfs.NfsDriver(configuration=self.configuration)
    def setUp(self):
        super(TestWindowsDriver, self).setUp()
        self._mox = mox_lib.Mox()
        self.stubs = stubout.StubOutForTesting()
        self.flags(windows_iscsi_lun_path='C:\iSCSIVirtualDisks', )
        self._setup_stubs()
        configuration = conf.Configuration(None)
        configuration.append_config_values(windows.windows_opts)

        self._driver = windows.WindowsDriver(configuration=configuration)
        self._driver.do_setup({})
Exemple #5
0
 def setUp(self):
     FLAGS.Reset()
     moe_app.InitForTest()
     self.stubs = stubout.StubOutForTesting()
     self.stubs.Set(db_client, '_Get', None)
     self.stubs.Set(db_client, '_Post', None)
     self.config_file_path = test_util.TestResourceFilename(
         'db_client/project_config.txt')
     self.name = 'foo'
     db_client.ServerBackedMoeDbClient = MockDbClient
     db_client.GetStoredProject = self._GetStoredProject
     test_util.MockOutMakeRepositoryConfig()
Exemple #6
0
    def setUp(self):
        self.lun_path_tempdir = tempfile.mkdtemp()
        super(TestWindowsDriver, self).setUp()
        self._mox = mox_lib.Mox()
        self.stubs = stubout.StubOutForTesting()
        self.flags(windows_iscsi_lun_path=self.lun_path_tempdir, )
        self._setup_stubs()
        configuration = conf.Configuration(None)
        configuration.append_config_values(windows.windows_opts)

        self._driver = windows.WindowsDriver(configuration=configuration)
        self._driver.do_setup({})
Exemple #7
0
    def setUp(self):
        self._mox = mox_lib.Mox()
        self._configuration = mox_lib.MockObject(conf.Configuration)
        self._configuration.append_config_values(mox_lib.IgnoreArg())
        self._configuration.glusterfs_shares_config = \
            self.TEST_SHARES_CONFIG_FILE
        self._configuration.glusterfs_mount_point_base = \
            self.TEST_MNT_POINT_BASE
        self._configuration.glusterfs_disk_util = 'df'
        self._configuration.glusterfs_sparsed_volumes = True

        self.stubs = stubout.StubOutForTesting()
        self._driver = glusterfs.GlusterfsDriver(
            configuration=self._configuration)
Exemple #8
0
 def setUp(self):
     super(TestNexentaNfsDriver, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     self.configuration = mox_lib.MockObject(conf.Configuration)
     self.configuration.nexenta_shares_config = None
     self.configuration.nexenta_mount_point_base = '$state_path/mnt'
     self.configuration.nexenta_sparsed_volumes = True
     self.configuration.nexenta_volume_compression = 'on'
     self.nms_mock = self.mox.CreateMockAnything()
     for mod in ('appliance', 'folder', 'server', 'volume', 'netstorsvc'):
         setattr(self.nms_mock, mod, self.mox.CreateMockAnything())
     self.stubs.Set(jsonrpc, 'NexentaJSONProxy',
                    lambda *_, **__: self.nms_mock)
     self.drv = nfs.NexentaNfsDriver(configuration=self.configuration)
     self.drv.shares = {}
     self.drv.share2nms = {}
Exemple #9
0
 def setUp(self):
     super(NfsDriverTestCase, self).setUp()
     self._mox = mox_lib.Mox()
     self.stubs = stubout.StubOutForTesting()
     self.configuration = mox_lib.MockObject(conf.Configuration)
     self.configuration.append_config_values(mox_lib.IgnoreArg())
     self.configuration.nfs_shares_config = None
     self.configuration.nfs_sparsed_volumes = True
     self.configuration.nfs_used_ratio = 0.95
     self.configuration.nfs_oversub_ratio = 1.0
     self._driver = nfs.NfsDriver(configuration=self.configuration)
     self._driver.shares = {}
     self._driver._remotefsclient._mount_options = None
     self._driver._remotefsclient._mount_base = self.TEST_MNT_POINT_BASE
     self.addCleanup(self.stubs.UnsetAll)
     self.addCleanup(self._mox.UnsetStubs)
Exemple #10
0
 def setUp(self):
     super(NfsDriverTestCase, self).setUp()
     self._mox = mox_lib.Mox()
     self.stubs = stubout.StubOutForTesting()
     self.configuration = mox_lib.MockObject(conf.Configuration)
     self.configuration.append_config_values(mox_lib.IgnoreArg())
     self.configuration.nfs_shares_config = None
     self.configuration.nfs_sparsed_volumes = True
     self.configuration.nfs_used_ratio = 0.95
     self.configuration.nfs_oversub_ratio = 1.0
     self.configuration.nfs_mount_point_base = self.TEST_MNT_POINT_BASE
     self.configuration.nfs_mount_options = None
     self.configuration.nas_secure_file_permissions = 'false'
     self.configuration.nas_secure_file_operations = 'false'
     self.configuration.volume_dd_blocksize = '1M'
     self._driver = nfs.NfsDriver(configuration=self.configuration)
     self._driver.shares = {}
     self.addCleanup(self.stubs.UnsetAll)
     self.addCleanup(self._mox.UnsetStubs)
Exemple #11
0
    def setUp(self):
        super(QuobyteDriverTestCase, self).setUp()
        self._mox = mox_lib.Mox()
        self._configuration = mox_lib.MockObject(conf.Configuration)
        self._configuration.append_config_values(mox_lib.IgnoreArg())
        self._configuration.quobyte_volume_url = \
            self.TEST_QUOBYTE_VOLUME
        self._configuration.quobyte_client_cfg = None
        self._configuration.quobyte_sparsed_volumes = True
        self._configuration.quobyte_qcow2_volumes = False
        self._configuration.quobyte_mount_point_base = \
            self.TEST_MNT_POINT_BASE

        self.stubs = stubout.StubOutForTesting()
        self._driver =\
            quobyte.QuobyteDriver(configuration=self._configuration,
                                  db=FakeDb())
        self._driver.shares = {}
        self._driver.set_nas_security_options(is_new_cinder_install=False)
        self.execute_as_root = False
        self.addCleanup(self._mox.UnsetStubs)
Exemple #12
0
def main():
    sys.path = extra_paths + sys.path
    os.environ['SERVER_SOFTWARE'] = 'Development via nose'
    os.environ['SERVER_NAME'] = 'Foo'
    os.environ['SERVER_PORT'] = '8080'
    os.environ['APPLICATION_ID'] = 'test-app-run'
    os.environ['USER_EMAIL'] = '*****@*****.**'
    os.environ['USER_ID'] = '42'
    os.environ['CURRENT_VERSION_ID'] = 'testing-version'
    os.environ['HTTP_HOST'] = 'some.testing.host.tld'
    import main as app_main
    from google.appengine.api import apiproxy_stub_map
    from google.appengine.api import datastore_file_stub
    from google.appengine.api import mail_stub
    from google.appengine.api import user_service_stub
    from google.appengine.api import urlfetch_stub
    from google.appengine.api.memcache import memcache_stub
    from google.appengine.api.taskqueue import taskqueue_stub
    apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
    apiproxy_stub_map.apiproxy.RegisterStub(
        'urlfetch', urlfetch_stub.URLFetchServiceStub())
    apiproxy_stub_map.apiproxy.RegisterStub(
        'user', user_service_stub.UserServiceStub())
    apiproxy_stub_map.apiproxy.RegisterStub(
        'datastore',
        datastore_file_stub.DatastoreFileStub('test-app-run', None, None))
    apiproxy_stub_map.apiproxy.RegisterStub(
        'memcache', memcache_stub.MemcacheServiceStub())
    apiproxy_stub_map.apiproxy.RegisterStub('mail',
                                            mail_stub.MailServiceStub())
    yaml_location = os.path.join(HERE, 'app')
    apiproxy_stub_map.apiproxy.RegisterStub(
        'taskqueue',
        taskqueue_stub.TaskQueueServiceStub(root_path=yaml_location))
    import django.test.utils
    django.test.utils.setup_test_environment()

    plugins = [AppEngineDatastoreClearPlugin()]

    if '--coverage' in sys.argv:
        from nose.plugins import cover
        plugin = cover.Coverage()
        from mox import stubout
        stubout_obj = stubout.StubOutForTesting()
        stubout_obj.SmartSet(plugin, 'begin', begin)
        plugins.append(plugin)

        args = [
            '--with-coverage', '--cover-package=soc.', '--cover-erase',
            '--cover-html', '--cover-html-dir=coverageResults'
        ]

        sys.argv.remove('--coverage')
        sys.argv += args
    else:
        load_melange()

    # Ignore functional, views and tasks tests temporarily
    args = ['--exclude=functional', '--exclude=^views$', '--exclude=^tasks$']
    sys.argv += args
    nose.main(addplugins=plugins)
Exemple #13
0
 def setUp(self):
   super(MockableTestCase, self).setUp()
   self.stubs = stubout.StubOutForTesting()
   self.mox = mox.Mox()
Exemple #14
0
def run_pyunit_tests():
    sys.path = extra_paths + sys.path
    os.environ['SERVER_SOFTWARE'] = 'Development via nose'
    os.environ['SERVER_NAME'] = 'Foo'
    os.environ['SERVER_PORT'] = '8080'
    os.environ['APPLICATION_ID'] = 'test-app-run'
    os.environ['USER_EMAIL'] = '*****@*****.**'
    os.environ['USER_ID'] = '42'
    os.environ['USER_IS_ADMIN'] = '0'
    os.environ['CURRENT_VERSION_ID'] = 'testing-version'
    os.environ['HTTP_HOST'] = 'some.testing.host.tld'
    os.environ['APPENGINE_RUNTIME'] = 'python27'
    setup_gae_services()

    # settings cannot be imported at module level, as it requires all
    # environmental variables to be already set
    import settings
    settings.MIDDLEWARE_CLASSES = list(
        settings.MIDDLEWARE_CLASSES) + ['test_utils.FakeBlobstoreMiddleware']

    import main as app_main
    import django.test.utils
    django.test.utils.setup_test_environment()

    plugins = [
        AppEngineDatastoreClearPlugin(),
        AppEngineMemcacheClearPlugin(),
        DefaultUserSignInPlugin()
    ]

    # For coverage
    if '--coverage' in sys.argv:
        from nose.plugins import cover
        plugin = cover.Coverage()
        plugin._orig_begin = plugin.begin
        stubout_obj = stubout.StubOutForTesting()
        stubout_obj.SmartSet(plugin, 'begin', begin)
        plugins.append(plugin)

        args = [
            '--with-coverage',
            '--cover-package=soc.,melange.,summerofcode.,codein.',
            '--cover-erase', '--cover-html',
            '--cover-html-dir=reports/py_coverage'
        ]

        sys.argv.remove('--coverage')
        sys.argv += args
    else:
        load_melange()

    # For multiprocess
    will_multiprocess = False
    for arg in sys.argv[1:]:
        if '--processes' in arg:
            will_multiprocess = True
            break
    if will_multiprocess:
        from nose.plugins import multiprocess
        stubout_obj = stubout.StubOutForTesting()
        stubout_obj.SmartSet(multiprocess, '__runner', multiprocess_runner)
        stubout_obj.SmartSet(multiprocess.MultiProcessTestRunner,
                             'checkCanSplit', staticmethod(checkCanSplit))
        # The default --process-timeout (10s) is too short
        sys.argv += ['--process-timeout=300']

    # Ignore functional and old_app tests
    args = ['--exclude=functional', '--exclude=^old_app$']
    sys.argv += args
    nose.run(addplugins=plugins)
Exemple #15
0
 def setUp(self):
     self._driver = nfs.NfsDriver()
     self._mox = mox_lib.Mox()
     self.stubs = stubout.StubOutForTesting()
Exemple #16
0
 def setUp(self):
     self.stubs = stubout.StubOutForTesting()
     super(RequestTest, self).setUp()
Exemple #17
0
    def __init__(self):
        """Creates a new ViewTest object.
    """

        #Creates a StubOutForTesting object
        self.stubout = stubout.StubOutForTesting()
Exemple #18
0
 def setUp(self):
   config_utils.MONOLITHIC_CODEBASE_NAME = 'monolith'
   config_utils.MONOLITHIC_CODEBASE_MIRROR = ('/path/to/monolith_mirror/'
                                              'monolith')
   self.stubs = stubout.StubOutForTesting()