Exemple #1
0
 def uninstall(self, request, pk=None):
     try:
         app = App.objects.get(pk=pk)
     except ObjectDoesNotExist:
         return Response("App Not Found to uninstall", status=404)
     try:
         installer = AppInstaller(app.name,
                                  app.store.id,
                                  app.version,
                                  user=request.user)
         installer.uninstall()
     except BaseException as e:
         return Response({"details": str(e)}, status=500)
     serializer = AppSerializer(app)
     return Response(serializer.data, status=200)
Exemple #2
0
 def test_app_installer(self):
     with lock:
         user = Profile.objects.filter(is_superuser=True).first()
         store_id = 1
         app_name = "cartoview_test_app"
         app_version = "0.1"
         app_installer = AppInstaller(app_name, store_id, app_version, user)
         installed_apps = app_installer.install()
         self.assertEqual(len(installed_apps), 1)
         apps_admin_url = reverse(
             "admin:%s_%s_changelist" %
             (App._meta.app_label, App._meta.model_name))
         data = {
             'action': 'suspend_selected',
             ACTION_CHECKBOX_NAME: [str(app.pk) for app in installed_apps]
         }
         resp = self.client.post(apps_admin_url, data)
         self.assertNotEqual(resp.status_code, 500)
         data = {
             'action': 'activate_selected',
             ACTION_CHECKBOX_NAME: [str(app.pk) for app in installed_apps]
         }
         resp = self.client.post(apps_admin_url, data)
         self.assertNotEqual(resp.status_code, 500)
         uninstalled = app_installer.uninstall()
         self.assertEqual(uninstalled, True)