Пример #1
0
 def test_run_bootstrap_all_functions(self, mock_defer):
     """Tests that run_bootstrap defers tasks for all four methods."""
     mock_defer.return_value = 'fake-task'
     self.assertFalse(config_model.Config.get('bootstrap_started'))
     bootstrap.run_bootstrap()
     self.assertEqual(len(mock_defer.mock_calls), 3)
     self.assertTrue(config_model.Config.get('bootstrap_started'))
Пример #2
0
  def run(self, request):
    """Runs request for the Bootstrap API."""
    self.check_xsrf_token(self.request_state)
    requested_tasks = {}
    for task in request.requested_tasks:
      requested_tasks[task.name] = {}
      for kwarg in task.kwargs:
        requested_tasks[task.name][kwarg.name] = kwarg.value

    bootstrap.run_bootstrap(requested_tasks)

    return message_types.VoidMessage()
Пример #3
0
 def test_run_bootstrap(self, mock_defer):
     """Tests that run_bootstrap defers tasks for all four methods."""
     mock_defer.return_value = 'fake-task'
     self.assertFalse(config_model.Config.get('bootstrap_started'))
     bootstrap.run_bootstrap({
         'bootstrap_bq_history': {},
         'bootstrap_chrome_ous': {},
         'bootstrap_datastore_yaml': {
             'yaml_input': 'fake-yaml'
         }
     })
     self.assertEqual(len(mock_defer.mock_calls), 3)
     self.assertTrue(config_model.Config.get('bootstrap_started'))
 def test_run_bootstrap_all_functions(self, mock_defer):
     """Tests that run_bootstrap defers tasks for all four methods."""
     mock_defer.return_value = 'fake-task'
     self.assertFalse(config_model.Config.get('bootstrap_started'))
     run_status_dict = bootstrap.run_bootstrap()
     self.assertDictEqual(run_status_dict, bootstrap._TASK_DESCRIPTIONS)
     self.assertEqual(len(mock_defer.mock_calls), 4)
     self.assertTrue(config_model.Config.get('bootstrap_started'))
  def run(self, request):
    """Runs request for the Bootstrap API."""
    self.check_xsrf_token(self.request_state)
    requested_tasks = {}
    for task in request.requested_tasks:
      requested_tasks[task.name] = {}
      for kwarg in task.kwargs:
        requested_tasks[task.name][kwarg.name] = kwarg.value

    run_status_dict = bootstrap.run_bootstrap(requested_tasks)

    response_message = bootstrap_messages.BootstrapStatusResponse()
    for name, description in run_status_dict.iteritems():
      response_message.tasks.append(
          bootstrap_messages.BootstrapTask(name=name, description=description))
    return response_message
Пример #6
0
 def test_run_bootstrap(self, mock_defer):
     """Tests that run_bootstrap defers tasks for 2 methods."""
     mock_defer.return_value = 'fake-task'
     self.assertFalse(config_model.Config.get('bootstrap_started'))
     run_status_dict = bootstrap.run_bootstrap({
         'bootstrap_bq_history': {},
         'bootstrap_datastore_yaml': {
             'yaml_input': 'fake-yaml'
         }
     })
     self.assertDictEqual(
         run_status_dict, {
             'bootstrap_bq_history':
             bootstrap._TASK_DESCRIPTIONS['bootstrap_bq_history'],
             'bootstrap_datastore_yaml':
             bootstrap._TASK_DESCRIPTIONS['bootstrap_datastore_yaml']
         })
     self.assertEqual(len(mock_defer.mock_calls), 2)
     self.assertTrue(config_model.Config.get('bootstrap_started'))
Пример #7
0
 def test_run_bootstrap_update(self, mock_defer):
     """Tests that run_bootstrap defers the correct tasks for an update."""
     mock_defer.return_value = 'fake-task'
     config_model.Config.set('running_version', '0.0.1-alpha')
     # This bootstrap task being completed would indicate that this is an update.
     bootstrap_status_model.BootstrapStatus.get_or_insert(
         'bootstrap_datastore_yaml').put()
     self.assertFalse(config_model.Config.get('bootstrap_started'))
     self.assertFalse(bootstrap._is_latest_version())
     run_status_dict = bootstrap.run_bootstrap()
     # Ensure that only _BOOTSTRAP_UPDATE_TASKS were run during an update.
     update_task_descriptions = {
         key: value
         for key, value in bootstrap._TASK_DESCRIPTIONS.iteritems()
         if key in bootstrap._BOOTSTRAP_UPDATE_TASKS
     }
     self.assertDictEqual(run_status_dict, update_task_descriptions)
     self.assertEqual(len(mock_defer.mock_calls),
                      len(update_task_descriptions))
     self.assertTrue(config_model.Config.get('bootstrap_started'))
Пример #8
0
 def test_run_bootstrap_bad_function(self):
     with self.assertRaises(bootstrap.Error):
         bootstrap.run_bootstrap({'bootstrap_bad_function': {}})
 def test_run_bootstrap_while_disabled(self):
     """Tests that bootstrapping is disallowed when constant False."""
     with self.assertRaises(bootstrap.Error):
         bootstrap.run_bootstrap({'bootstrap_fake_method': {}})