Esempio n. 1
0
 def create(self, request, *args, **kwargs):
     if not self.request.data:
         raise ValidationError('Received no config options.')
     for key in self.request.data:
         value = self.request.data.get(key)
         try:
             if value:
                 conf.set(key, value)
             else:
                 conf.delete(key)
         except ConfException as e:
             raise ValidationError(e)
     return Response(data={}, status=status.HTTP_200_OK)
Esempio n. 2
0
 def test_not_allowed_to_create(self):
     conf.set(key=ALLOW_USER_OWNERSHIP, value=False)
     data = {'name': 'new_project'}
     resp = self.auth_client.post(self.url, data)
     assert resp.status_code == status.HTTP_400_BAD_REQUEST
     conf.delete(key=ALLOW_USER_OWNERSHIP)
Esempio n. 3
0
 def test_cannot_create(self):
     conf.set(key=ALLOW_USER_OWNERSHIP, value=False)
     with self.assertRaises(ValidationError):
         ProjectFactory()
     conf.delete(key=ALLOW_USER_OWNERSHIP)