def test_query(self):
    """Tests successful execution of the query command."""
    mock_options = self.setup_mock_options(force=True, shards="0")
    with contextlib.nested(
        patch('twitter.common.app.get_options', return_value=mock_options),
        patch('apache.aurora.admin.admin.make_admin_client',
            return_value=create_autospec(spec=AuroraClientAPI)),
        patch('apache.aurora.admin.admin.CLUSTERS', new=self.TEST_CLUSTERS)
    ) as (_, mock_make_admin_client, _):

      api = mock_make_admin_client.return_value
      api.query.return_value = self.create_response(self.create_task())

      query([self.TEST_CLUSTER, 'test_role', 'test_job'], mock_options)

      api.query.assert_called_with(self.task_query())
Esempio n. 2
0
  def test_query(self):
    """Tests successful execution of the query command."""
    mock_options = self.setup_mock_options(force=True, shards="0")
    with contextlib.nested(
        patch('twitter.common.app.get_options', return_value=mock_options),
        patch('apache.aurora.admin.admin.make_admin_client',
            return_value=create_autospec(spec=AuroraClientAPI)),
        patch('apache.aurora.admin.admin.CLUSTERS', new=self.TEST_CLUSTERS)
    ) as (_, mock_make_admin_client, _):

      api = mock_make_admin_client.return_value
      api.query.return_value = self.create_response(self.create_task())

      query([self.TEST_CLUSTER, 'test_role', 'test_job'], mock_options)

      api.query.assert_called_with(self.task_query())
  def test_query_fails(self):
    """Tests failed execution of the query command."""
    mock_options = self.setup_mock_options(shards="0")
    with contextlib.nested(
        patch('twitter.common.app.get_options', return_value=mock_options),
        patch('apache.aurora.admin.admin.make_admin_client',
            return_value=create_autospec(spec=AuroraClientAPI)),
        patch('apache.aurora.admin.admin.CLUSTERS', new=self.TEST_CLUSTERS)
    ) as (_, mock_make_admin_client, _):

      api = mock_make_admin_client.return_value
      api.query.return_value = self.create_response(self.create_task())

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

      api.query.assert_called_with(self.task_query())
Esempio n. 4
0
  def test_query_fails(self):
    """Tests failed execution of the query command."""
    mock_options = self.setup_mock_options(shards="0")
    with contextlib.nested(
        patch('twitter.common.app.get_options', return_value=mock_options),
        patch('apache.aurora.admin.admin.make_admin_client',
            return_value=create_autospec(spec=AuroraClientAPI)),
        patch('apache.aurora.admin.admin.CLUSTERS', new=self.TEST_CLUSTERS)
    ) as (_, mock_make_admin_client, _):

      api = mock_make_admin_client.return_value
      api.query.return_value = self.create_response(self.create_task())

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

      api.query.assert_called_with(self.task_query())