Beispiel #1
0
def _list_resource_descriptors(args, _):
  """Lists the resource descriptors in the project."""
  project_id = args['project']
  pattern = args['type'] or '*'
  descriptors = gcm.ResourceDescriptors(project_id=project_id)
  dataframe = descriptors.as_dataframe(pattern=pattern)
  return _render_dataframe(dataframe)
Beispiel #2
0
    def test_constructor_minimal(self, mock_context_default):
        mock_context_default.return_value = self.context

        descriptors = gcm.ResourceDescriptors()

        expected_client = gcm._utils.make_client(context=self.context)
        self.assertEqual(descriptors._client.project, expected_client.project)
        self.assertEqual(descriptors._client.connection.credentials,
                         expected_client.connection.credentials)

        self.assertIsNone(descriptors._filter_string)
        self.assertIsNone(descriptors._descriptors)
Beispiel #3
0
  def test_list_w_api_filter(self, mock_api_list_descriptors):
    mock_api_list_descriptors.return_value = self._list_resources_get_result()

    descriptors = gcm.ResourceDescriptors(
        filter_string=FILTER_STRING, context=self.context)
    resource_descriptor_list = descriptors.list()

    mock_api_list_descriptors.assert_called_once_with(
        filter_string=FILTER_STRING)
    self.assertEqual(len(resource_descriptor_list), 2)
    self.assertEqual(resource_descriptor_list[0].type, RESOURCE_TYPES[0])
    self.assertEqual(resource_descriptor_list[1].type, RESOURCE_TYPES[1])
Beispiel #4
0
  def test_constructor_maximal(self):
    context = self._create_context(PROJECT)
    descriptors = gcm.ResourceDescriptors(
        filter_string=FILTER_STRING, project_id=PROJECT, context=context)

    expected_client = gcm._utils.make_client(
        context=context, project_id=PROJECT)
    self.assertEqual(descriptors._client.project, expected_client.project)
    self.assertEqual(descriptors._client.connection.credentials,
                     expected_client.connection.credentials)

    self.assertEqual(descriptors._filter_string, FILTER_STRING)
    self.assertIsNone(descriptors._descriptors)
Beispiel #5
0
def _list_resource_descriptors(args, _):
    """Lists the resource descriptors in the project."""
    project_id = args['project']
    pattern = args['type'] or '*'
    return gcm.ResourceDescriptors(project_id=project_id).table(
        pattern=pattern)
Beispiel #6
0
 def setUp(self):
     self.context = self._create_context()
     self.descriptors = gcm.ResourceDescriptors(context=self.context)