Ejemplo n.º 1
0
    def test_set_cache_value(self, mock_cache, mock_get_cache_key):
        value = "some_value"
        attribute = 'progress'
        model_name = 'ExportTaskRecord'
        uid = 'test_uid'
        etr = ExportTaskRecord(uid=uid)
        expiration = 1
        cache_key = "{}.{}.{}".format('ExportTaskRecord', uid, attribute)
        mock_get_cache_key.return_value = cache_key

        set_cache_value(obj=etr, attribute=attribute, uid=uid, model_name=model_name, value=value, expiration=1)
        mock_get_cache_key.assert_called_once_with(obj=etr, attribute=attribute, uid=uid, model_name=model_name)
        mock_cache.set.assert_called_once_with(cache_key, value, timeout=1)
Ejemplo n.º 2
0
    def test_set_cache_value(self, mock_cache, mock_get_cache_key):
        value = "some_value"
        attribute = "progress"
        model_name = "ExportTaskRecord"
        uid = "test_uid"
        etr = ExportTaskRecord(uid=uid)
        cache_key = "{}.{}.{}".format("ExportTaskRecord", uid, attribute)
        mock_get_cache_key.return_value = cache_key

        set_cache_value(obj=etr,
                        attribute=attribute,
                        uid=uid,
                        model_name=model_name,
                        value=value,
                        expiration=1)
        mock_get_cache_key.assert_called_once_with(obj=etr,
                                                   attribute=attribute,
                                                   uid=uid,
                                                   model_name=model_name)
        mock_cache.set.assert_called_once_with(cache_key, value, timeout=1)
Ejemplo n.º 3
0
 def estimated_finish(self, value, expiration=DEFAULT_CACHE_EXPIRTATION):
     return set_cache_value(obj=self, attribute="estimated_finish", value=value, expiration=expiration)
Ejemplo n.º 4
0
 def progress(self, value, expiration=DEFAULT_CACHE_EXPIRTATION):
     return set_cache_value(obj=self, attribute="progress", value=value, expiration=expiration)
Ejemplo n.º 5
0
 def status(self, value, expiration=DEFAULT_CACHE_EXPIRATION):
     return set_cache_value(obj=self,
                            attribute="status",
                            value=value,
                            expiration=expiration)
Ejemplo n.º 6
0
 def message(self, value, expiration=DEFAULT_CACHE_EXPIRATION):
     return set_cache_value(obj=self,
                            attribute="message",
                            value=value,
                            expiration=expiration)