예제 #1
0
    def test_update_ocp_added_via_sources(self):
        """Raise error on update to ocp provider added via sources."""
        # Create Provider
        credentials = {"cluster_id": "cluster_id_1001"}
        provider_authentication = ProviderAuthentication.objects.create(
            credentials=credentials)
        with patch("masu.celery.tasks.check_report_updates"):
            provider = Provider.objects.create(
                name="ocpprovidername",
                created_by=self.user,
                customer=self.customer,
                authentication=provider_authentication,
            )
        provider_uuid = provider.uuid

        sources = Sources.objects.create(source_id=1,
                                         auth_header="testheader",
                                         offset=1,
                                         koku_uuid=provider_uuid)
        sources.save()
        put_request = self._create_put_request(self.user)
        with tenant_context(self.tenant):
            manager = ProviderManager(provider_uuid)
            with self.assertRaises(ProviderManagerError):
                manager.update(put_request)
    def test_update_ocp_added_via_sources(self):
        """Raise error on update to ocp provider added via sources."""
        # Create Provider
        provider_authentication = ProviderAuthentication.objects.create(provider_resource_name='cluster_id_1001')
        provider = Provider.objects.create(name='ocpprovidername',
                                           created_by=self.user,
                                           customer=self.customer,
                                           authentication=provider_authentication,)
        provider_uuid = provider.uuid

        sources = Sources.objects.create(source_id=1,
                                         auth_header='testheader',
                                         offset=1,
                                         koku_uuid=provider_uuid)
        sources.save()
        put_request = self._create_put_request(self.user)
        with tenant_context(self.tenant):
            manager = ProviderManager(provider_uuid)
            with self.assertRaises(ProviderManagerError):
                manager.update(put_request)
    def test_update_ocp_not_added_via_sources(self):
        """Return None on update to ocp provider not added via sources."""
        # Create Provider
        provider_authentication = ProviderAuthentication.objects.create(provider_resource_name='cluster_id_1001')
        provider = Provider.objects.create(name='ocpprovidername',
                                           created_by=self.user,
                                           customer=self.customer,
                                           authentication=provider_authentication,)
        provider_uuid = provider.uuid

        put_request = self._create_put_request(self.user)
        with tenant_context(self.tenant):
            manager = ProviderManager(provider_uuid)
            self.assertIsNone(manager.update(put_request))
예제 #4
0
    def test_update_ocp_not_added_via_sources(self):
        """Return None on update to ocp provider not added via sources."""
        # Create Provider
        credentials = {"cluster_id": "cluster_id_1001"}
        provider_authentication = ProviderAuthentication.objects.create(credentials=credentials)
        with patch("masu.celery.tasks.check_report_updates"):
            provider = Provider.objects.create(
                name="ocpprovidername",
                created_by=self.user,
                customer=self.customer,
                authentication=provider_authentication,
            )
        provider_uuid = provider.uuid

        put_request = self._create_put_request(self.user)
        with tenant_context(self.tenant):
            manager = ProviderManager(provider_uuid)
            self.assertIsNone(manager.update(put_request))