Esempio n. 1
0
    def testRegexFilter(self, track):
        self._SetUpForTrack(track)
        expected_request = self.messages.ComputeDiskTypesAggregatedListRequest(
            filter='(name eq pd-.*)',
            maxResults=500,
            project=self.Project(),
        )
        scoped_disk_types = [
            ('zones/arctic-north1',
             test_resources.MakeDiskTypes(self.messages,
                                          self.track.prefix,
                                          scope_type='region',
                                          scope_name='arctic-north1')),
            ('zones/antactic-south2',
             test_resources.MakeDiskTypes(self.messages,
                                          self.track.prefix,
                                          scope_type='region',
                                          scope_name='antactic-south2')),
        ]
        response = self._GetDiskTypeAggregatedListResponse(scoped_disk_types)

        self.mock_client.diskTypes.AggregatedList.Expect(
            expected_request, response)
        self.Run('compute disk-types list --regexp pd-.*')
        self.AssertOutputEquals(textwrap.dedent("""\
            NAME        LOCATION SCOPE VALID_DISK_SIZES
            pd-standard                10GB-10TB
            pd-ssd                     10GB-1TB
            pd-standard                10GB-10TB
            pd-ssd                     10GB-1TB
            """),
                                normalize_space=True)
Esempio n. 2
0
    def testDiskTypesCompleter(self):
        self._SetUpForTrack(calliope_base.ReleaseTrack.ALPHA)
        expected_request = self.messages.ComputeDiskTypesAggregatedListRequest(
            filter=None,
            maxResults=500,
            project=self.Project(),
        )
        scoped_disk_types = [
            ('zones/arctic-north1-a',
             test_resources.MakeDiskTypes(self.messages,
                                          self.track.prefix,
                                          scope_name='arctic-north1-a')),
            ('regions/arctic-north1',
             test_resources.MakeDiskTypes(self.messages,
                                          self.track.prefix,
                                          scope_type='region',
                                          scope_name='arctic-north1')),
        ]
        response = self._GetDiskTypeAggregatedListResponse(scoped_disk_types)

        self.mock_client.diskTypes.AggregatedList.Expect(
            expected_request, response)
        self.mock_client.diskTypes.AggregatedList.Expect(
            expected_request, response)

        self.RunCompleter(
            completers.DiskTypesCompleter,
            expected_command=[
                [
                    'alpha',
                    'compute',
                    'disk-types',
                    'list',
                    '--uri',
                    '--filter=-zone:*',
                    '--quiet',
                    '--format=disable',
                ],
                [
                    'alpha',
                    'compute',
                    'disk-types',
                    'list',
                    '--uri',
                    '--filter=zone:*',
                    '--quiet',
                    '--format=disable',
                ],
            ],
            expected_completions=['pd-ssd', 'pd-standard'],
            args={'project': 'my-project'},
            cli=self.cli,
        )
        self.AssertOutputEquals('')
Esempio n. 3
0
 def testTabularOutput(self):
     get_zonal_resources = self.StartObjectPatch(
         lister,
         'GetZonalResourcesDicts',
         return_value=resource_projector.MakeSerializable(
             test_resources.MakeDiskTypes(self.messages,
                                          self.track.prefix)),
     )
     self.Run("""
     compute disk-types list
     """)
     get_zonal_resources.assert_called_once_with(
         service=self.compute.diskTypes,
         project='my-project',
         requested_zones=[],
         filter_expr=None,
         http=self.mock_http(),
         batch_url=self.batch_url,
         errors=[])
     self.AssertOutputEquals(textwrap.dedent("""\
         NAME        ZONE   VALID_DISK_SIZES
         pd-standard zone-1 10GB-10TB
         pd-ssd      zone-1 10GB-1TB
         """),
                             normalize_space=True)
Esempio n. 4
0
 def SetUp(self):
     lister_patcher = mock.patch(
         'googlecloudsdk.api_lib.compute.lister.GetZonalResourcesDicts',
         autospec=True)
     self.addCleanup(lister_patcher.stop)
     self.mock_get_zonal_resources = lister_patcher.start()
     self.mock_get_zonal_resources.return_value = (
         resource_projector.MakeSerializable(
             test_resources.MakeDiskTypes(self.messages,
                                          self.track.prefix)))