Example #1
0
    def setUp(self):
        super(TestQuotaList, self).setUp()

        self.projects_mock.get.return_value = fakes.FakeResource(
            None,
            copy.deepcopy(identity_fakes.PROJECT),
            loaded=True,
        )

        self.identity = self.app.client_manager.identity
        self.identity.tenants.list = mock.Mock(return_value=[self.project])

        self.network = self.app.client_manager.network
        self.compute = self.app.client_manager.compute
        self.volume = self.app.client_manager.volume

        self.network.get_quota = mock.Mock(return_value=self.quota_list)
        self.compute.quotas.get = mock.Mock(return_value=self.quota_list1)
        self.volume.quotas.get = mock.Mock(return_value=self.quota_list2)

        self.network.get_quota_default = mock.Mock(
            return_value=self.default_quota)
        self.compute.quotas.defaults = mock.Mock(
            return_value=self.default_quota1)
        self.volume.quotas.defaults = mock.Mock(
            return_value=self.default_quota2)

        self.cmd = quota.ListQuota(self.app, None)
    def setUp(self):
        super(TestQuotaList, self).setUp()

        # Work with multiple projects in this class
        self.projects_mock.get.side_effect = self.projects
        self.projects_mock.list.return_value = self.projects

        self.compute_quotas = [
            compute_fakes.FakeQuota.create_one_comp_quota(),
            compute_fakes.FakeQuota.create_one_comp_quota(),
        ]
        self.compute_default_quotas = [
            compute_fakes.FakeQuota.create_one_default_comp_quota(),
            compute_fakes.FakeQuota.create_one_default_comp_quota(),
        ]
        self.compute = self.app.client_manager.compute
        self.compute.quotas.defaults = mock.Mock(
            side_effect=self.compute_default_quotas, )

        self.compute_reference_data = (
            self.projects[0].id,
            self.compute_quotas[0].cores,
            self.compute_quotas[0].fixed_ips,
            self.compute_quotas[0].injected_files,
            self.compute_quotas[0].injected_file_content_bytes,
            self.compute_quotas[0].injected_file_path_bytes,
            self.compute_quotas[0].instances,
            self.compute_quotas[0].key_pairs,
            self.compute_quotas[0].metadata_items,
            self.compute_quotas[0].ram,
            self.compute_quotas[0].server_groups,
            self.compute_quotas[0].server_group_members,
        )

        self.network_quotas = [
            network_fakes.FakeQuota.create_one_net_quota(),
            network_fakes.FakeQuota.create_one_net_quota(),
        ]
        self.network_default_quotas = [
            network_fakes.FakeQuota.create_one_default_net_quota(),
            network_fakes.FakeQuota.create_one_default_net_quota(),
        ]
        self.network = self.app.client_manager.network
        self.network.get_quota_default = mock.Mock(
            side_effect=self.network_default_quotas, )

        self.network_reference_data = (
            self.projects[0].id,
            self.network_quotas[0].floating_ips,
            self.network_quotas[0].networks,
            self.network_quotas[0].ports,
            self.network_quotas[0].rbac_policies,
            self.network_quotas[0].routers,
            self.network_quotas[0].security_groups,
            self.network_quotas[0].security_group_rules,
            self.network_quotas[0].subnets,
            self.network_quotas[0].subnet_pools,
        )

        self.volume_quotas = [
            volume_fakes.FakeQuota.create_one_vol_quota(),
            volume_fakes.FakeQuota.create_one_vol_quota(),
        ]
        self.volume_default_quotas = [
            volume_fakes.FakeQuota.create_one_default_vol_quota(),
            volume_fakes.FakeQuota.create_one_default_vol_quota(),
        ]
        self.volume = self.app.client_manager.volume
        self.volume.quotas.defaults = mock.Mock(
            side_effect=self.volume_default_quotas, )

        self.volume_reference_data = (
            self.projects[0].id,
            self.volume_quotas[0].backups,
            self.volume_quotas[0].backup_gigabytes,
            self.volume_quotas[0].gigabytes,
            self.volume_quotas[0].per_volume_gigabytes,
            self.volume_quotas[0].snapshots,
            self.volume_quotas[0].volumes,
        )

        self.cmd = quota.ListQuota(self.app, None)