Exemplo n.º 1
0
 def checkSingleObjectDoesNotExist(self, expected_exc=ObjectDoesNotExist):
     with self.assertRaisesRegexp(expected_exc,
                                  r'matching query does not exist.'):
         with unpack_exception():
             self.task.delay(self.MODEL_SYMBOL,
                             {'char': str(uuid4()),
                              'id': randint(100, 1000)}).get()
Exemplo n.º 2
0
 def checkSingleObjectDoesNotExist(self, expected_exc=ObjectDoesNotExist):
     with self.assertRaisesRegexp(expected_exc,
                                  r'matching query does not exist.'):
         with unpack_exception():
             self.task.delay(self.MODEL_SYMBOL, {
                 'char': str(uuid4()),
                 'id': randint(100, 1000)
             }).get()
Exemplo n.º 3
0
 def testSingleObjectDoesNotExist(self):
     """ Raise exception if cannot find object in single mode  """
     with self.assertRaisesRegexp(ModelTaskError,
                                  r'matching query does not exist.'):
         with unpack_exception():
             self.task.delay(self.MODEL_SYMBOL,
                             {'char': str(uuid4()),
                              'id': randint(100, 1000)}).get()
Exemplo n.º 4
0
 def testSingleObjectDoesNotExist(self):
     """ Raise exception if cannot find object in single mode  """
     with self.assertRaisesRegexp(ModelTaskError,
                                  r'matching query does not exist.'):
         with unpack_exception():
             self.task.delay(self.MODEL_SYMBOL, {
                 'char': str(uuid4()),
                 'id': randint(100, 1000)
             }).get()
Exemplo n.º 5
0
    def testNoExistSerializer(self):
        """ Test not existing serializer """
        char_val = str(uuid4())
        expected = get_model_dict(self.models[0])

        with self.assertRaises(ModelTaskError):
            with unpack_exception():
                self.task.delay(self.MODEL_SYMBOL,
                                {'char': char_val, 'id': expected['id']},
                                serializer_cls='not.existing.symbol').get()
Exemplo n.º 6
0
    def testNoValidSerializer(self):
        """ Test not valid serializer """
        char_val = str(uuid4())
        expected = get_model_dict(self.models[0])

        with self.assertRaisesRegexp(ModelTaskError, r'not a DRF serializer'):
            serializer_cls = 'celery_rpc.tests.models:SimpleModel'
            with unpack_exception():
                self.task.delay(self.MODEL_SYMBOL,
                                {'char': char_val, 'id': expected['id']},
                                serializer_cls=serializer_cls).get()
Exemplo n.º 7
0
 def testSingleObjectAlreadyExist(self):
     """ Raise exception if object already exists """
     pk = randint(1, 1000)
     obj = NonAutoPrimaryKeyModel.objects.create(pk=pk)
     with self.assertRaisesRegexp(ModelTaskError,
                                  r'primary key|PRIMARY KEY') as ctx:
         with unpack_exception():
             r = self.task.delay(
                 'celery_rpc.tests.models:NonAutoPrimaryKeyModel',
                 {'id': obj.pk})
             r.get()
     self.assertNotEquals(self.models[0].id, ctx.exception.args[1]['id'])
Exemplo n.º 8
0
    def testNoExistSerializer(self):
        """ Test not existing serializer """
        char_val = str(uuid4())
        expected = get_model_dict(self.models[0])

        with self.assertRaises(ModelTaskError):
            with unpack_exception():
                self.task.delay(self.MODEL_SYMBOL, {
                    'char': char_val,
                    'id': expected['id']
                },
                                serializer_cls='not.existing.symbol').get()
Exemplo n.º 9
0
    def testNoValidSerializer(self):
        """ Test not valid serializer """
        char_val = str(uuid4())
        expected = get_model_dict(self.models[0])

        with self.assertRaisesRegexp(ModelTaskError, r'not a DRF serializer'):
            serializer_cls = 'celery_rpc.tests.models:SimpleModel'
            with unpack_exception():
                self.task.delay(self.MODEL_SYMBOL, {
                    'char': char_val,
                    'id': expected['id']
                },
                                serializer_cls=serializer_cls).get()
Exemplo n.º 10
0
 def testSingleObjectAlreadyExist(self):
     """ Raise exception if object already exists """
     pk = randint(1, 1000)
     obj = NonAutoPrimaryKeyModel.objects.create(pk=pk)
     with self.assertRaisesRegexp(
             ModelTaskError,
             r'primary key|PRIMARY KEY') as ctx:
         with unpack_exception():
             r = self.task.delay(
                 'celery_rpc.tests.models:NonAutoPrimaryKeyModel',
                 {'id': obj.pk})
             r.get()
     self.assertNotEquals(self.models[0].id, ctx.exception.args[1]['id'])