def test_get(self): cache.set('foo', 'bar', 60) cache.set('moof', 'baz', 1) simple_cache = SimpleCache() self.assertEqual(simple_cache.get('foo'), 'bar') self.assertEqual(simple_cache.get('moof'), 'baz') self.assertEqual(simple_cache.get(''), None)
def test_set(self): simple_cache = SimpleCache() simple_cache.set('foo', 'bar') simple_cache.set('moof', 'baz', timeout=1) # Use the underlying cache system to verify. self.assertEqual(cache.get('foo'), 'bar') self.assertEqual(cache.get('moof'), 'baz') # Check expiration. time.sleep(2) self.assertEqual(cache.get('moof'), None)
def test_set(self): simple_cache = SimpleCache(timeout=1) with mock.patch.object(simple_cache, 'cache', mock.Mock(wraps=simple_cache.cache)) as mocked_cache: simple_cache.set('foo', 'bar', timeout=10) simple_cache.set('moof', 'baz') # Use the underlying cache system to verify. self.assertEqual(cache.get('foo'), 'bar') self.assertEqual(cache.get('moof'), 'baz') # make sure cache was called with correct timeouts. self.assertEqual(mocked_cache.set.call_args_list[0][0][2], 10) self.assertEqual(mocked_cache.set.call_args_list[1][0][2], 1)
class Meta: queryset = Device.objects.all() authentication = ApiKeyAuthentication() authorization = DjangoAuthorization() filtering = {} excludes = ('save_priorities', 'max_save_priority', 'dns_info', 'snmp_name') cache = SimpleCache() throttle = CacheThrottle(throttle_at=THROTTLE_AT, timeframe=TIMEFREME, expiration=EXPIRATION)
class Meta: allowed_methods = ["get"] cache = SimpleCache() fields = [ "author", "author_email", "created", "description", "download_uri", "downloads", "license", "maintainer", "maintainer_email", "package", "platform", "classifiers", "requires_python", "summary", "version" ] include_absolute_url = True include_resource_uri = False queryset = Release.objects.all()
class Meta: queryset = ServiceAreas.objects.all() resource_name = "service_areas" excludes = ['id'] authorization = Authorization() always_return_data = True cache = SimpleCache(timeout=10) filtering = { 'geom': ALL, }
class Meta: cache = SimpleCache() queryset = TelechatAgendaItem.objects.all() serializer = api.Serializer() #resource_name = 'telechatagendaitem' filtering = { "id": ALL, "text": ALL, "type": ALL, "title": ALL, }
class Meta: cache = SimpleCache() queryset = RelatedIpr.objects.all() serializer = api.Serializer() #resource_name = 'relatedipr' filtering = { "id": ALL, "source": ALL_WITH_RELATIONS, "target": ALL_WITH_RELATIONS, "relationship": ALL_WITH_RELATIONS, }
class Meta: queryset = Subscribed.objects.all() serializer = api.Serializer() cache = SimpleCache() #resource_name = 'subscribed' filtering = { "id": ALL, "time": ALL, "email": ALL, "lists": ALL_WITH_RELATIONS, }
class Meta: cache = SimpleCache() queryset = GroupStateName.objects.all() #resource_name = 'groupstatename' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: cache = SimpleCache() queryset = FeedbackTypeName.objects.all() #resource_name = 'feedbacktypename' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: cache = SimpleCache() queryset = IprLicenseTypeName.objects.all() #resource_name = 'iprlicensetypename' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: cache = SimpleCache() queryset = RoomResourceName.objects.all() resource_name = 'roomresourcename' # Needed because tastypie otherwise removes 'resource' from the name filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: cache = SimpleCache() queryset = DocReminderTypeName.objects.all() #resource_name = 'docremindertypename' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: cache = SimpleCache() queryset = SessionStatusName.objects.all() #resource_name = 'sessionstatusname' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: cache = SimpleCache() queryset = TimeSlotTypeName.objects.all() #resource_name = 'timeslottypename' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: cache = SimpleCache() queryset = StreamName.objects.all() #resource_name = 'streamname' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: queryset = BlogPost.objects.published() resource_name = "app" fields = ['keywords_string', 'slug', 'title', 'id'] allowed_methods = ['get'] serializer = Serializer() cache = SimpleCache(timeout=100) filtering = { 'slug': ALL_WITH_RELATIONS, 'title': ALL_WITH_RELATIONS }
class Meta: cache = SimpleCache() queryset = DBTemplateTypeName.objects.all() #resource_name = 'dbtemplatetypename' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: cache = SimpleCache() queryset = EmailSubscription.objects.all() serializer = api.Serializer() #resource_name = 'emailsubscription' filtering = { "id": ALL, "email": ALL_WITH_RELATIONS, "notify_on": ALL, "community_list": ALL_WITH_RELATIONS, }
class Meta: cache = SimpleCache() queryset = NomineePositionStateName.objects.all() #resource_name = 'nomineepositionstatename' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: queryset = DataStore.objects.all() resource_name = 'entry' authorization = Authorization() filtering = { "device_name": ALL, "magnification": ALL, "field_of_view": ALL, "range": ALL } cache = SimpleCache(timeout=10)
class Meta: cache = SimpleCache() queryset = ReviewResultName.objects.all() #resource_name = 'reviewresultname' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: queryset = ReviewSecretarySettings.objects.all() serializer = api.Serializer() cache = SimpleCache() #resource_name = 'reviewsecretarysettings' filtering = { "id": ALL, "remind_days_before_deadline": ALL, "team": ALL_WITH_RELATIONS, "person": ALL_WITH_RELATIONS, }
class Meta: cache = SimpleCache() queryset = TopicAudienceName.objects.all() #resource_name = 'topicaudiencename' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: allowed_methods = ["get"] cache = SimpleCache() fields = ["trove"] filtering = { "trove": ALL, } include_resource_uri = False ordering = ["trove"] queryset = TroveClassifier.objects.all() resource_name = "classifier"
class Meta: cache = SimpleCache() queryset = DocTagName.objects.all() #resource_name = 'doctagname' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: always_return_data = True allowed_methods = ['get', 'post', 'put', 'patch', 'options', 'head'] authentication = Authentication authorization = DjangoAuthorization() validation = Validation() collection_name = 'data' cache = SimpleCache(timeout=10) throttle = CacheDBThrottle(throttle_at=settings.THROTTLE_TIMEOUT)
class Meta: cache = SimpleCache() queryset = IntendedStdLevelName.objects.all() #resource_name = 'intendedstdlevelname' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: cache = SimpleCache() queryset = SessionPresentation.objects.all() serializer = api.Serializer() #resource_name = 'sessionpresentation' filtering = { "id": ALL, "rev": ALL, "session": ALL_WITH_RELATIONS, "document": ALL_WITH_RELATIONS, }
class Meta: cache = SimpleCache() queryset = LiaisonStatementPurposeName.objects.all() #resource_name = 'liaisonstatementpurposename' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }
class Meta: queryset = List.objects.all() serializer = api.Serializer() cache = SimpleCache() #resource_name = 'list' filtering = { "id": ALL, "name": ALL, "description": ALL, "advertised": ALL, }
class Meta: cache = SimpleCache() queryset = IprDisclosureStateName.objects.all() #resource_name = 'iprdisclosurestatename' filtering = { "slug": ALL, "name": ALL, "desc": ALL, "used": ALL, "order": ALL, }