Example #1
0
 def test_runs_staging_cleanup(self, mock_cleaner, mock_Thread, mock_conf,
                               mock_load):
     mock_conf.return_value = []
     wsgi_app.init_app()
     mock_Thread.assert_called_once_with(
         target=mock_cleaner().clean_orphaned_staging_residue, daemon=True)
     mock_Thread.return_value.start.assert_called_once_with()
Example #2
0
 def test_run_cache_prefetcher(self, mock_prefetcher, mock_Timer, mock_conf,
                               mock_load):
     self.config(cache_prefetcher_interval=10)
     self.config(flavor='keystone+cachemanagement', group='paste_deploy')
     mock_conf.return_value = []
     wsgi_app.init_app()
     mock_Timer.assert_called_once_with(10, mock.ANY, (mock_prefetcher(), ))
     mock_Timer.return_value.start.assert_called_once_with()
Example #3
0
 def test_wsgi_init_sets_thread_settings(self, mock_config_files,
                                         mock_set_model, mock_load):
     mock_config_files.return_value = []
     self.config(task_pool_threads=123, group='wsgi')
     common.DEFAULT_POOL_SIZE = 1024
     wsgi_app.init_app()
     # Make sure we declared the system threadpool model as native
     mock_set_model.assert_called_once_with('native')
     # Make sure we set the default pool size
     self.assertEqual(123, common.DEFAULT_POOL_SIZE)
     mock_load.assert_called_once_with('glance-api')
Example #4
0
 def test_policy_enforcement_valid_falsy_configuration(
         self, mock_load_app, mock_set, mock_config_files):
     # This is effectively testing the default values, but we're doing that
     # to make sure nothing bad happens at runtime in the default case when
     # validating policy enforcement configuration.
     self.config(enforce_new_defaults=False, group='oslo_policy')
     self.config(enforce_secure_rbac=False)
     self.assertTrue(wsgi_app.init_app())
Example #5
0
 def test_wsgi_init_registers_exit_handler(self, mock_config_files,
                                           mock_set_model,
                                           mock_load, mock_exit):
     mock_config_files.return_value = []
     wsgi_app.init_app()
     mock_exit.assert_called_once_with(wsgi_app.drain_threadpools)
Example #6
0
 def test_policy_enforcement_valid_truthy_configuration(
         self, mock_load_app, mock_set, mock_config_files):
     self.config(enforce_new_defaults=True, group='oslo_policy')
     self.config(enforce_secure_rbac=True)
     self.assertTrue(wsgi_app.init_app())
Example #7
0
 def test_run_cache_prefetcher_middleware_disabled(self, mock_prefetcher,
                                                   mock_Timer, mock_conf,
                                                   mock_load):
     mock_conf.return_value = []
     wsgi_app.init_app()
     mock_Timer.assert_not_called()