Exemplo n.º 1
0
  def test_query(self):
    """Tests successful execution of the query command."""
    mock_options = self.setup_mock_options(force=True)
    mock_api, mock_scheduler_proxy = self.create_mock_api()
    with contextlib.nested(
        patch('twitter.common.app.get_options', return_value=mock_options),
        patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler_proxy),
        patch('apache.aurora.client.commands.admin.CLUSTERS', new=self.TEST_CLUSTERS)):

      mock_scheduler_proxy.getTasksStatus.return_value = self.create_response(self.create_task())

      query([self.TEST_CLUSTER], mock_options)

      mock_scheduler_proxy.getTasksStatus.assert_called_with(self.task_query())
Exemplo n.º 2
0
  def test_query_fails(self):
    """Tests failed execution of the query command."""
    mock_options = self.setup_mock_options()
    mock_api, mock_scheduler_proxy = self.create_mock_api()
    with contextlib.nested(
        patch('twitter.common.app.get_options', return_value=mock_options),
        patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler_proxy),
        patch('apache.aurora.client.commands.admin.CLUSTERS', new=self.TEST_CLUSTERS)):

      mock_scheduler_proxy.getTasksStatus.return_value = self.create_response(self.create_task())

      try:
        query([self.TEST_CLUSTER], mock_options)
      except SystemExit:
        pass
      else:
        assert 'Expected exception is not raised'
Exemplo n.º 3
0
    def test_query(self):
        """Tests successful execution of the query command."""
        mock_options = self.setup_mock_options(force=True)
        mock_api, mock_scheduler_proxy = self.create_mock_api()
        with contextlib.nested(
                patch('twitter.common.app.get_options',
                      return_value=mock_options),
                patch('apache.aurora.client.api.SchedulerProxy',
                      return_value=mock_scheduler_proxy),
                patch('apache.aurora.client.commands.admin.CLUSTERS',
                      new=self.TEST_CLUSTERS)):

            mock_scheduler_proxy.getTasksStatus.return_value = self.create_response(
                self.create_task())

            query([self.TEST_CLUSTER], mock_options)

            mock_scheduler_proxy.getTasksStatus.assert_called_with(
                self.task_query())
Exemplo n.º 4
0
    def test_query_fails(self):
        """Tests failed execution of the query command."""
        mock_options = self.setup_mock_options()
        mock_api, mock_scheduler_proxy = self.create_mock_api()
        with contextlib.nested(
                patch('twitter.common.app.get_options',
                      return_value=mock_options),
                patch('apache.aurora.client.api.SchedulerProxy',
                      return_value=mock_scheduler_proxy),
                patch('apache.aurora.client.commands.admin.CLUSTERS',
                      new=self.TEST_CLUSTERS)):

            mock_scheduler_proxy.getTasksStatus.return_value = self.create_response(
                self.create_task())

            try:
                query([self.TEST_CLUSTER], mock_options)
            except SystemExit:
                pass
            else:
                assert 'Expected exception is not raised'